Hi,
When using grid.filterBy(0,function(val,rowId){}) after having done a grid.clearAndLoad just before, the filterBy seems to iterate the grid using old rowIds from the previous listing in it and getting error “Cannot read property ‘_childindexes’ of null” a lot.
I noticed the error only occurs if you have already performed filterBy() on the populated grid and then reloaded (using clearAndLoad(), but also tried adding grid.clearAll() with the same result) with a smaller set.
The stacktrace:
Uncaught TypeError: Cannot read property '_childIndexes' of null dhtmlx.js:875
dhtmlXGridObject.cells dhtmlx.js:875
multiSearch tab_attest_single.jsp:1201
(anonymous function) tab_attest_single.jsp:1192
dhtmlXGridObject._filterA dhtmlx.js:963
dhtmlXGridObject.filterBy dhtmlx.js:962
filterGrid tab_attest_single.jsp:1190
Non-working code:
grid.filterBy(1, function(val,rowId){
return multiSearch(rowId,s.toUpperCase());
});
To get it working, I hade to change it to:
grid.filterBy(1, function(val,rowId){
return grid.doesRowExist(rowId) && multiSearch(rowId,s.toUpperCase());
});
Function multiSearch, for reference:
function multiSearch(rowId,s){
// search against column 2
if (grid.cells(rowId,1)!=null && grid.cells(rowId,1).getValue().toUpperCase().indexOf(s)> -1){
return true;
}
// search against column 3
else if (grid.cells(rowId,2)!=null && grid.cells(rowId,2).getValue().toUpperCase().indexOf(s)> -1){
return true;
}
// search against column 4
else if (grid.cells(rowId,3)!=null && grid.cells(rowId,3).getValue().toUpperCase().indexOf(s)> -1){
return true;
}
// search against column 7
else if (grid.cells(rowId,6)!=null && grid.cells(rowId,6).getValue().indexOf(s)> -1){
return true;
}
// search against column 8
else if (grid.cells(rowId,7)!=null && grid.cells(rowId,7).getValue().toUpperCase().indexOf(s)> -1){
return true;
}
// search notes in userdata
else if (grid.getUserData(rowId,'notes') != null && grid.getUserData(rowId,'notes').toUpperCase().indexOf(s)> -1){
return true;
}
else{
return false;
}
}
Could you please look into that?
Regards,
Johnny
PS. Guessing it is due to old rowids in some grid internal rowbuffer probably?
Adding this snippet before my grid.clearAndLoad(…) of course fixes the issue, but I’d like to keep to documented API calls, if possible.
grid._f_rowsBuffer = null;
PS2. This is somewhat related to my request here: viewtopic.php?f=2&t=38128 DS.