Hi!
Context: I am currently working on a project that is using WebHierarchicalDataGrid (ig v18.1), I was asked to add the summary "sum" for TimeSpan dataType Columns. This columns are added dynamically.
Now, yes, I currently know that sum only works for numerical types, so I decided to create a Custom Summary. I should be easy.
Everything was going empirically well. Until I realize that for some reason It seems that it is not the same process for adding a custom summary for WebDataGrid and for WebHierarchicalDataGrid.
I am expecting that a custom summary for WebHierarchicalDataGrid would behave like the example for WebDataGrid (https://ko.infragistics.com/samples/aspnet/data-grid/summaries-custom-summary) but i can not find a working example of WHDG (It does not even appears on https://ko.infragistics.com/samples/aspnet/hierarchical-data-grid/summaries so it gives me the imppression that I could not be implemented on WHDG)
Recalling that columns are added dynamically, I cannot fix any keycolumn as documentation examples are shown And I cannot use the ig wazard/helper.
Any lights to follow on this situation.?
Thanks in advance!
Hello,
Thank you for posting to Infragistics Community!
While it is true that there is no demo of applying custom summaries to the WebHierarchicalDataGird, according to this page from our documentation, they are supported.
Attached you will find a minimal sample with an hierarchical grid having its data and hierarchy dynamically defined as well as a custom summary applied. Please, check it out and let me know if you need further assistance on the matter. Although, I would like to point out that, even with a dynamic setup, the columns have to have keys assigned in order to define summaries, or perform any other relevant operations with them.
However, please keep in mind that version 18.1 is retired and not longer eligible for developer support services. More info can be found on our Product Lifecycle page.
Best regards, Bozhidara Pachilova Associate Software Developer
WHDGDynamicColumns.zip
I am reattaching the sample from my previous reply containing a fix related to assigning the summaries only on the first load, as the initial version could cause errors. In addition, the sample is a bit simplified, and the bands and columns are auto generated.
Please, test the newer version of the sample and please, excuse the inconvenience. I hope the example helps implement custom summaries in the WebHierarchicalGrid on your side. If you require any further assistance on the matter, please, let me know.
1778.WHDGDynamicColumns2.zip
Hello!Returning with this. I was checking it, and, everything went good with the initial case. Even though, child band should be able to add a custom summary as well. I tried to implement it, taking and modifying the code for the principal grid on your example, but, no success.
I try to change the "ChUpdate" column behaviour in order to have the custom summary.
Let me know if you have any idea to handle this.
(I only modify the WebForm1.aspx.cs. tested on 2022.2)
WebForm1.aspx.zip
Thank you for following up.
After further investigation, I determined that when it comes to a WebHierarchicalDataGrid with auto-generated columns and bands, and when the behaviors are not defined in the markup, there are some differences in the code-behind setup.
To start with, the behaviors, “SummaryRow” in this case, have to be created on the ContainerGrid, which can be accessed through this.WebHierarchicalDataGrid1.GridView.
This means also modifying the SummaryRow properties on the WebHierarchicalDataGrid1.GridView.Behaviors.SummaryRow object.
Furthermore, the child custom summaries have to be defined for a Row Island, which could be done in the RowIslandCreated event. The CalculateCustomSummary handler for the row islands has to be hooked in the RowIslandDataBinding event of the WebHierarchicalDataGrid. This also means passing the corresponding row island on defining the SummaryRowSetting object, for example:
SummaryRowSetting summaryRowSetting = new SummaryRowSetting(ri, "ItemCh");
Attached you will find a modified version of the previous sample demonstrating this. On my side, everything seems to work as expected with the introduced changes:
Please, test the new sample on your side and let me know if it helps achieve your requirement.
0160.WHDGCustomSummaries.zip
Hello!that is an interesting finding, I'm going to try it. Thanks!
Hi, sure, please test the suggested approach and keep me posted on your progress.
Best regards, Bozhidara Pachilova