Interactive Grid shortcodes

Disable Reorder and Resize

// Disable Reorder and Resize column
function(options){
    options.defaultGridViewOptions = {
        reorderColumns: false,
        resizeColumns: false
    };
    
    return options;
}

Hide Save Button

#gridID button[data-action="save"] {
    display: none !important;
}

Process GRID model

//Dynamic action on Grid ROW selection Changed
model = this.data.model;

for ( i = 0; i < this.data.selectedRecords.length; i++ ) {  
  model.getValue( this.data.selectedRecords[i], "<COLUMN_ALIAS>");
  * * * * *
}
// Selected row Using Grid ID

let gridView = apex.region("<Grid ID>").widget().interactiveGrid("getViews").grid;
let selectedRecords = gridView.getSelectedRecords();

// We get the index for the column in the IG model
let col_1_idx = gridView.modelColumns['<COLUMN 1>'].index;
let col_2_idx = gridView.modelColumns['<COLUMN 1>'].index;
* * * * * * * *
* * * * * * * *
if(selectedRecords.length === 1){    
    console.log(selectedRecords[0][col_1_idx]);
    console.log(selectedRecords[0][col_2_idx]);
}

GRID actions

// Save
apex.region("emp").call("getActions").invoke("save");

// Edit
apex.region("emp").call("getActions").invoke("edit");

// refresh

apex.region("emp").call("getActions").invoke("refresh");

// Selected Refresh

apex.region("emp").call("getActions").invoke("selection-refresh");

Horizontal Scrollbars

#grid_id .a-GV-w-hdr{
    overflow-x: auto !important;
}

Persistent Selection

function (config){
    config.defaultGridViewOptions = {
        persistSelection: true;
    };
    return config;
}

Add Row using JS

  // Add Row
  var $widget = apex.region('<grid_id>').widget();
  var $grid   = $widget.interactiveGrid('getViews', 'grid');
  var $model  = $grid.model;

  // insert new record on a model
  var newRecordId = $model.insertNewRecord();

  // get the new record
  var $newRecord = $model.getRecord(newRecordId);

  //update record values
  $model.setValue($newRecord, '<COLUMN_ALIAS 1>', 'Custom Value');
  * * * * * * * * * * * * 
  * * * * * * * * * * * * 
  $model.setValue($newRecord, '<COLUMN_ALIAS 2>', 'Custom Value');