Reputation: 6929
I have an interactive grid with custom action defined on it. What I am trying to do is loop through the grid, grabbing all the selected records, then loop through the records and update a single database field for each record, setting it to 0.
I am using the following code to loop through the records, grabbing record ID:
view=apex.region("myGrid").widget().interactiveGrid("getViews","grid");
if (view.supports.edit)
{
model=view.model;
records=view.getSelectedRecords();
if(records.length>0)
{
for(i=0;i< records.length; i++)
{
$record_id= model.getValue(records[i], "RECORD_ID");
//update the database here UPDATE TABLE1 SET Flag=0 WHERE RECORD_ID=$record_id
}
}
}
what is the best way to perform an update from here?
Upvotes: 1
Views: 1691
Reputation: 1033
Had a pretty similair situation a bit back. I wanted to go through an IG and change one column for every selected record. I set up a Dynamic action triggered on a button, and had it run the following Javascript, and after the javascript set up another tru action for submit page, otherwise you still need to save manually. This was my solution:
var g = apex.region('MY_INTERACTIVE_GRID').widget().interactiveGrid('getViews','grid');
var r = g.getSelectedRecords();
for(i = 0; i < r.length; i++) {
g.model.setValue(r[i], 'MY_COLLUMN', 'VALUE_I_WANT');
}
Hope this helps, a lot of the solutions I found didnt work for me, this one worked(Im on 18.2)
Upvotes: 1