Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Please ask technical questions in the appropriate category. Thank you!

Interactive Grid "setSelectedRecords" function not working APEX 23.x

GrlicaAApr 15 2024

Hi guys,

Here is a demo of my “Bug” find.
https://apex.oracle.com/pls/apex/r/trtdemo/ig-bug-setselectedrecords/home

When I use the function "setSelectedRecords" on already displayed record the function works as it should. In case when the record is in a model but not displayed in a grid, it cannot be selected/focused. I see this as a bug since that was working in previous versions.

If you guys can check this out and find a workaround it will be highly appreciated. This is a MUST-have for a lot of our applications.

1. Step => Use fetchAll to populate the model with this record
2. Step select the record with "setSelectedRecords"

function setSelectedRecordByID(pGrid, pID) {
   let widget      = apex.region(pGrid ).widget(); 
   let grid        = widget.interactiveGrid("getViews","grid");  
   let model       = grid.model; 
   let record      = model.getRecord(pID);
   if (record) {
       console.log("STEP 1. fetch record: ", record);
       grid.setSelectedRecords([record],true);  
       console.log("STEP 2. got record try setSelectedRecords: ", record);
   }
   else {
       console.log("STEP 1. setSelectedRecordByID, record is null now fetchAll");
       
       model.fetchAll( function( status ) {
           console.log("setSelectedRecordByID, fetchAll status: ", status);
           if ( status.done ) {
               record = model.getRecord(pID);
               grid.setSelectedRecords([record],true);  
               console.log("STEP 2. got record try setSelectedRecords: ", record);
           }
       });
   }
}
This post has been answered by John Snyders-Oracle on Apr 29 2024
Jump to Answer
Comments
Post Details
Added on Apr 15 2024
4 comments
279 views