This turned into a miniseries. First it was about focusing on a cell and then on entering the cell in edit mode, but I figure there is a related thing one might want to do. You could want to read the data in a cell once the Interactive Grid (IG) has been loaded.
Maybe you need it for some other processing or you want to present something in the IG also in another region. Say that you show the user the last three times a job was executed and you want to suggest the next start time to be based on the longest time they took. Sure you could go back to the database and pick it up with a MAX(), but you already have the data read for the IG, so why add more load on the database when the data is already available.
var ig = apex.region("ABC").widget().interactiveGrid("getViews","grid"); var rec = ig.model.recordAt(2); var val = ig.model.getValue(rec,"ORDER_DATETIME"); apex.message.alert( "Date = " + val );
ABC is the static ID of the IG. Wi grab the third record in the IG and in it we get the value for the ORDER_DATETIME column. We could get it by just accessing the field in the record by index, but getting it through the model and stating the name of the column makes for much more readable code to me.
console.log( "Date = " + val );
If you want to control so it is only emitted when debug of a certain level is enabled, replace it with this.
apex.debug.info("Date = " + val);
With this you can retrieve data from the records in the IG, either to present it or to evaluate and make decisions based on the data the user can see.
There are many use cases for these techniques. Being able to act on data the user is actually seeing let’s you customise their experience in ways not possible to achieve on the server side.