Forum Stats

  • 3,873,233 Users
  • 2,266,521 Discussions
  • 7,911,476 Comments

Discussions

How to get previous and next row data in an Interactive grid

josjos
josjos Member Posts: 3 Blue Ribbon

Hello,

I'm using apex 21.2

I get the ID from first and last record like this:

var grid = apex.region('MY_INTERACTVE_GRID').call('getCurrentView'),
    model = grid.model,
    totalRecords = model.getTotalRecords(),
    firstRecord = model.recordAt(1),
    lastRecord = model.recordAt(totalRecords  - 1);

console.log(firstRecord[1]);
console.log(lastRecord[1]);

I also can get the selected id record ...

var model = this.data.model;
if (this.data != null){
  if(this.data.selectedRecords[0] != null){
    v_curr_id = model.getValue(this.data.selectedRecords[0], "ID");
  }
}
apex.item("P1_SELECTED_ID").setValue(v_curr_id);

but how do I get the ID from the previous and next row ?

Best Answers

  • Hamza Al-abbasi
    Hamza Al-abbasi Member Posts: 774 Bronze Crown
    edited Oct 1, 2022 8:29AM Answer ✓

    Hello josjos,

    but how do I get the ID from the previous and next row ?

    You mean the Next/Previous record ID of selected row ? if it is try this :

    var region$ = apex.region("[IG_STATIC_ID]").widget(),
        currentRow$ = region$.find(".a-GV-row.is-selected"),
        prevRowID = currentRow$.prev().data("id"),
        nextRowID = currentRow$.next().data("id");
    
    console.log("Previous Row ID = " + prevRowID);
    console.log("Next Row ID = " + nextRowID);
    
    josjos
  • Hamza Al-abbasi
    Hamza Al-abbasi Member Posts: 774 Bronze Crown
    edited Oct 3, 2022 11:19AM Answer ✓
    var region$ = apex.region("[IG_STATIC_ID]"),
        widget$ = region$.widget(),
        model = region$.call("getCurrentView").model,
        currentRow$ = widget$.find(".a-GV-row.is-selected"),
        prevRowID = currentRow$.prev().data("id"),
        nextRowID = currentRow$.next().data("id");
    
    console.log("Previous Row ID = " + model.getRecordValue(prevRowID, "P_ID");
    console.log("Next Row ID = " + model.getRecordValue(nextRowID, "P_ID");
    


    josjos

Answers