Can someone please tell me the best way to calculate the sum of a column of values when the grid has:
autoCommit: false
aggregrateTransactions: true
My scenario is that I have a "Services" grid with a service, quantity, price, extended price.
Users can add, edit, and delete with the grid. There is no filtering, sorting , or paging. The sum of the extended price must be kept in a field outside of the grid on a form (like an invoice). There is actually another grid for parts. When the user submits the invoice, I send the ig_transactions along with the form for processing. There are setting for the grid to calculate the extended price based on quantity and unit price.
I have added the feature "Summaries" but it only will work when the autoCommit is set to true. It will not sum the rows that are edited or added when autoCommit is false.
I am using the following for now unless there is a better way. Please advise.
In the grid rowDeleting event:
//set all values to zero
rowDeleting:function (evt, ui) { $gridJobService.igGridUpdating("updateRow", ui.rowID, { Quantity: 0, UnitPrice: 0, ExtPrice: 0 });
}
In the grid rowDeleted and editRowEnded events:
var ExtPrice = 0, id = "", value = 0;
$gridJobService.igGrid("allRows").each(function (index) {
id = $(this).attr("data-id");
try{
value = $gridJobService.igGrid("getCellValue", id, "ExtPrice");
catch(err) {
value = 0.00;
ExtPrice += parseFloat(value);
});
//update the field on the form
$("#TotalServiceAmount").igNumericEditor("value", ExtPrice);
Hello,
Please help me to solve this issue on Ignite-UI grid, if you find any solution please reply on same.
How to get or set customize "resultTemplate" property from Summary feature ?
We calculate the footer value then want to display it in the customized footer, since we have 3 footer rows, So we are planning to use custom template for the footer.
e.g.<table ><tr><td> Footer Column Value </tr></td></table>
Thanks,
Yuvraj
Can you please help me to set customize Summary value on "Grid Load" & Any column "value changed" events for
igGrid (if column having different Currencies) ?
If possible please send me chunk of code for it.
I tried this code, but not working...
$("#grid").on("iggriddatabound", function (event, ui) { if (_isDataBound === false) { _isDataBound = true; } else { return; } var i, grid = ui.owner, TotalUnitPrice = 0.00, ds = grid.dataSource, data = ds.data(), dataLength = data.length; //var rows = $("#grid").igGrid("rows"); for (i = 0; i < dataLength; i++) { if (data[i]["UnitPrice"] * data[i]["UnitsInStock"] < 1000) { //data[i]["IsPromotion"] = true; } else { //data[i]["IsPromotion"] = false; } if (data[i]["UnitPrice"] != "") { TotalUnitPrice += data[i]["UnitPrice"]; } } $("#grid_summaries_footer_row_text_container_custom1_UnitPrice").html(TotalUnitPrice); });
Many Thanks,
Thank you for your quick reply.
I have to send the data at one time unfortunately.
The workaround works well for what I need it for.
It would be nice if the Summaries feature would take pending transactions into account though.
Thank you,
Michael
Hello mhead1 ,
Thank you for posting in our forum.
For the summary feature the summaries will only get calculated once the changes made on the grid have been committed.
If autoCommit is set to true that will happen the moment you end the editing of the cell. You could also manually commit the changes using the commit method:
$(".selector").igGrid("commit");
If you have a remote data source set with an updateUrl then when you commit the grid will attempt to send the transactions to that url.
If the data source is local it will reflect the changes in that data source.
In both cases after that the pending transactions in ig_transactions will be cleared.
Depending on your scenario you could specify an update url and commit the changes in the grid in its data source separately.
If your business logic does not allow you to commit the grid’s changes then you won’t be able to use the summary feature. In that case you’d have to use your custom approach to calculate the sum manually.
Let me know if you have any questions.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://es.infragistics.com/support