jQWidgets Forums
jQuery UI Widgets › Forums › Grid › SubTotal in grouping
Tagged: aggregates, excel, grid, groups, groupsrenderer, jqxgrid, renderer, sum
This topic contains 6 replies, has 4 voices, and was last updated by Dimitar 9 years, 10 months ago.
-
AuthorSubTotal in grouping Posts
-
Hi
How to make a subtotal of Total(Price * Quantity) och quantity in grouping efter example Product Name? Tks!
Regards
LeeHello Lee,
Here is the modified function groupsrenderer of the demo Groups Renderer:
var groupsrenderer = function (text, group, expanded, data) { if (data.groupcolumn.datafield == 'price' || data.groupcolumn.datafield == 'quantity') { if (data.subItems.length > 0) { var aggregateP = this.getcolumnaggregateddata("price", ['sum'], false, data.subItems); var aggregateQ = this.getcolumnaggregateddata("quantity", ['sum'], true, data.subItems); var aggregate = new Object(); aggregate.sum = aggregateP.sum * aggregateQ.sum; } else { var rows = new Array(); var getRows = function (group, rows) { if (group.subGroups.length > 0) { for (var i = 0; i < group.subGroups.length; i++) { getRows(group.subGroups[i], rows); } } else { for (var i = 0; i < group.subItems.length; i++) { rows.push(group.subItems[i]); } } } getRows(data, rows); var aggregate = this.getcolumnaggregateddata(data.groupcolumn.datafield, ['sum'], true, rows); } return '<div class="' + toThemeProperty('jqx-grid-groups-row') + '" style="position: absolute;"><span>' + text + ', </span>' + '<span class="' + toThemeProperty('jqx-grid-groups-row-details') + '">' + "Total" + ' (' + aggregate.sum + ')' + '</span></div>'; } else { return '<div class="' + toThemeProperty('jqx-grid-groups-row') + '" style="position: absolute;"><span>' + text + '</span>'; }}
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thanks, Dimitar, it works.
Regards,
LeeHi Dimitar,
Even though I am able to sum up the grouped data using jqwidgets Grouping and Aggregates, I am supposed to display functionality of subtotal which we can see in excelsheet,
I want to do like this
taskA 1 5 3
taskA 4 8 5
sum 5 13 8
taskB 8 1 0
taskB 1 5 8
sum 9 6 8I am trying to obtain the jqxgrid as in the following example:
Is this work around do able?
Thanks & Regards,
ssp
Hello ssp,
These subtotals can be calculated with aggregates and displayed in the group headers (as shown in the example). However, they cannot be displayed on separate rows, unfortunately.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar, can we now display aggregates in the separate rows.
I figured there might have been developments over two years. ThanksHi drv232,
Unfortunately, this functionality is still not available and is not currently in our development plans.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.