Here is my situation:
I'm using summaries (Sum Operand only) on two columns of my grid. This is working perfectly.
I have checkbox selection of rows enabled on my grid, and would like to show a summary for only those rows selected, below the existing out of the box summaries.
I beleive my declaration is correct in MVC as follows (I will just show AmountDue summary, as AmountToPay will be pretty much the same logic)
summaries.ColumnSetting().ColumnKey("AmountDue")... //etc
// Below - works fine
builder.SummaryOperand() .DecimalDisplay(2) .Type(SummaryFunction.Sum) .Active(true) .RowDisplayLabel("Total Due");
// Added this below
builder.SummaryOperand() .DecimalDisplay(2) .Type(SummaryFunction.Custom) .Active(true) .SummaryCalculator("calculateSelectedAmountDue") .RowDisplayLabel("Total Selected Due:");
So based on documentation I should provide a function that can calculate the sum of all selected rows - for column ("AmountDue")
I'm not certain what the structure of this function should look like, how do I get the collection of selected rows and sum the AmountDue column? I was thinking of handling it via iggridsummariessummariescalculating but the code will be looking for "calculateSelectedAmountDue"
Hi Borislav,
We have the same requirement based on check box selection we need to display the summaries. We are able to calculate the sum , avg based on row selection but we are unable to re bind to the grid. Would you please provide the sample code so it will helpful.
When initial grid load we are able to display the summaries in iggrid. By using below code setting in grid initialize
{columnKey: "TotaQuantity", allowSummaries: displayOnlyRequiredSummaries, summaryOperands: [{ "rowDisplayLabel": "Sum", "type": sum, "active": true, "order": 0, decimalDisplay: 2, summaryCalculator: $.proxy(TotalQuantitySummary, this) },
{ "rowDisplayLabel": "Avg", "type": avg, "active": true, "order": 0, decimalDisplay: 2, summaryCalculator: $.proxy(AvgQuantitySummary, this) }]
},
Hi Borislav! :)
I have actually accomplished what I set out to do, turns out the compact mode setting was incorrect. I am rendering the summaries correctly now. My only problem is this:
Consider the following summary builder:
builder.SummaryOperand() .Type(SummaryFunction.Custom) .Active(true) .RowDisplayLabel("Total Selected Due") .SummaryCalculator("mySummaryFunction");
I have two different grids that I will be using the custom function on, I would just have to pass in a different selector for jQuery to find the grid I want to work with. But so far I am not able to find a way to pass a parameter to the SummaryCalculator function, that is, I couldn't do something like:
.SummaryCalculator("mySummaryFunction(#gridId)"; <-- anyway to pass a parameter?
Hi Kunal,I see that you're on a row with this scenario :)Don't be discouraged - it's a bit simpler than you think (but no - there's no out-of-the-box solution for this scenario).Tomorrow (hopefully) I will compose a simple HTML sample to demonstrate it (MVC has no part in this seeing as how you need to do custom calculations on even the out-of-the-box summaries (count, min, max and so on)).Just a sneak peak at the idea: you do the calculations based on the selected rows and then replace the value, rendered for the summary of the given column.Cheers,Borislav
Turns out, if you use the same summary calculator function name, they will line up - now, I could use the same function name if there was a way to parameterize the function call, so I could pass in the column name and the grid name : /
Ok Parameters aside: it seems like if you use a custom calculator on adjacent rows they don't line up, see below. I tried setting the order but no luck.
Hope someone from Infragistics answers this one :)