Hi,
Let's assume that your entire data is in this kind of JSON
{ "ProductCollection": [ { "Sales": 956, ... }, ... }
And you want to get the maximum value of the column "Sales", then use this
var myTableArray = this.getView().byId("table").getModel().getProperty('/ProductCollection'), maxVal = myTableArray[0].Sales; //Assuming we have data, assertion checks needed for (var i = 1; i < myTableArray.length; i++) { if (myTableArray[i].Sales > maxVal ) { maxVal = myTableArray[i].Sales; } }
I'm sure you can optimize this maximum finding. If so, revert back here (also if this is not what you meant...).
The oData linked to the table, will have a parameter sales. You might have linked this to the table.
Since oData holds the data, its better to read the sales values from the oData parameter - sales.
Now, if you want to find the maximum sales of all the sales values, use the script var _array =[1,3,2];Math.max.apply(Math,_array);// 3
What do you wnat to do with the maximum sales value? Highlight it in the table or show it soemwhere else?
Add comment