Page 2 of 2

Re: Identifying row in a grid by the way the user sorts in RPG

Posted: Thu Dec 12, 2019 3:27 pm
by DanD
It turns out that the code isn't working in the fashion I'm expecting - the for loop is reading based on the the RRN - not the order in which the grid is sorted by the end-user.

Instead of this:

Code: Select all

var myGrid  = getObj("s1_items");
var gridrec = myGrid.grid.getRecordCount();

for (var i=1;i<=gridrec;i++) {
  myGrid.grid.setDataValue(i, "S1_SORTROW", i);
}
I tried this & it seems to be returning the desired results:

Code: Select all

var myGrid  = getObj("s1_items");
var gridrec = myGrid.grid.getRecordCount();

for (var i=1;i<=gridrec;i++) {
  var rrn = myGrid.grid.getRRN(i);
  myGrid.grid.setDataValue(rrn, "S1_SORTROW", i);
}