Hi
I am trying to calculate the sum of Item cost fields in a sub grid. Item cost field is currency type.
I have attached an event on grid refresh. In that event, looping through all the rows, extracting the item cost value from the cell and adding. I have used the below code
To extract from grid:
var grid = Xrm.Page.ui.controls.get("RequestedItems")._control;
var ids = grid.get_innerControl().get_allRecordIds();
var totalRequestCost=0;
In the for loop:
var x = grid.get_innerControl().getCellValue("item_cost", ids[i]);
totalRequestCost = parseFloat(totalRequestCost) + parseFloat(x);
Issue: The parseFloat is giving the NAN error.
I tried by removing "$" sign and "," from the "x" before converting to parseFloat.
Also tried using parseFloat(x,10), parseFloat(x,10).toFixed(2) and parseInt etc.
Every where i am getting the NAN error.
Please let me know how to add currency fields. Any help would be appreciated