getAllDataValues( applyFilter )



This method returns an array containing all fields in all rows of a grid.Ā  The data does not have to be visible on the display when the method is called.

This method will only work when using a Rich Display or Genie Handler to write data to the subfile.Ā  (For database-driven grids or grids rendered from 5250 screens without a handler, you can call the getCellValue API in a loop.)

Parameter:

  • applyFilter - if true, rows that have been filtered out of the grid will not be returned in the array.Ā  If false, all rows will be returned.Ā  If this parameter is not provided, it will default to true.

Return Value:

  • An array of objects representing all fields in all rows of the grid.Ā  The fields in the object correspond to the uppercase field names that have been bound to properties used in the grid.

Example:

This example calculates the total of all PSTOCK values in a grid named PRODSFL.Ā  It will not include rows that have been filtered out of the grid.Ā  The total is placed in a field with an id of "PSTOCK_total".

function calcTotal() { var data = getObj("PRODSFL").grid.getAllDataValues(true); var totQty = 0; for (var i=0; i<data.length; i++) { totQty += Number(data[i]["PSTOCK"]); } pui.set("PSTOCK_total", "Total Qty: " + totQty.toFixed(0)); }

This function could be called from a screen's "onload" event to show the total in the grid and/or from the grid's "onfilterchange" event to be updated when the user changes the filter.