Reputation: 2030
How can i get all data (rows) and access them with their field name instead if index in Javascript. For example (invalid code)
let grid = apex.region('myGridStaticID');
let data = grid.allRows;
for(let i = 0; i < data.length; i++)
{
//console.log(data[i][0]);
console.log(data[i].COLUMN1);
console.log(data[i].COLUMN3);
}
Further i find it difficult to follow the documentation https://docs.oracle.com/en/database/oracle/apex/23.1/aexjs/interactiveGrid.html
for example there is a method getViews
and i tried to call it like this which didn't work.
apex.region("[region static ID]").getViews();
It worked like this
apex.region("[region static ID]").widget().interactiveGrid("getViews", "grid");
Can you please explain/point out if the above line is documented as well.
Upvotes: 0
Views: 1337
Reputation: 2030
let igId = "region_static_id";
let grid = apex.region(igId).widget().interactiveGrid("getViews","grid");
let model = grid.model;
let key_COLUMN1 = model.getFieldKey("COLUMN1");
let key_COLUMN3 = model.getFieldKey("COLUMN3");
let data = [];
let grow = null;
//## Look for a better solution
model.forEach(function(row) {
grow = row;
data.push(grow);
});
for(let i = 0; i < data.length; i++)
{
console.log(data[i][key_COLUMN1]);
console.log(data[i][key_COLUMN3]);
}
Upvotes: 0