Hi
igHierarchicalGrid allow add subtotals, when datasource looks like this:
var data = [ { ID: 1, Test: "Test1",Arr: [{ID: 1, data: "data1"}, {ID: 2, data: "data2"}, {ID: 3, data: "data3"}]}, { ID: 2,Test: "Test2",
Arr: [{ID: 1, data: "data4"}, {ID: 2, data: "data5"}, {ID: 3, data: "data6"}]
}]
But igHierarchicalGrid allow us group by some property dynamically and i need add subtotals for this case. For example we have such datasource, then group by Test property. Now we have group which contains 2 records. How i can add subtotals for them?
var data = [{ ID: 1, Test: "Test1",},{ID: 2,Test: "Test1",
Regards
Hello Aliaksey,
Thank you for posting in our community.
If I understood your requirement right, you need a Grouping feature which includes a custom information about the group (a summary). Therefore I would suggest you to take a look at the following links:
- the first one is a sample that demonstrates Grouping with Summaries: http://igniteui.com/grid/grouping
- the second one is a documentation overview of the Grouping with Summaries feature: http://es.infragistics.com/help/jquery/igHierarchicalGrid_Grouping_with_Summaries.html#_Ref322004154
I've created also a sample with similar scenario for your reference.
Please let me know if you need any further assistance.
Sincerely,
Tsanna
Hi Tsanna.
Thanks for your answer, I investigated linked pages, but didn't found answer. Summaries in your sample don't understandable enough. I want to find a way to apply subtotals like in hierarchical data source to flat data source.
Hello Aliaksei,
One possible approach for this scenario could be handling the row added event and regrouping again all the grid records. In order to implement this it is needed the following settings to be applied:
Setting the grid autoCommit property to true;
Enabling the grouping on the grid initialization be setting the isGroupBy column setting property to true:
name: "GroupBy",
type: "local",
columnSettings:[
…
{columnKey:"ProductDescription", isGroupBy: true}
]
},
Handling the rowAdded and editRowEnded event by firstly ungrouping the grid and applying grouping again.
This approach is applicable when grouping is performed by one column. If it needed to group by multiple columns it would be needed some additional functionality to be added.
I have attached a sample for your reference. Feel free to modify it and use it if needed.
If you have any further questions or comments feel free to contact us again.