problem with row Ids

var colIndex = mygrid.getColIndexById("neighbor"); mygrid.forEachRow(function(id){ if(mygrid.cells(id,colIndex).getValue()=="x") mygrid.setColWidth(colIndex,"250"); });

This code segment doesn’t seem to work, does it look ok to you? If I try

alert(mygrid.cells(10,colIndex).getValue());

I get a "Cannot read property ‘_childIndexes’ of null " type error, I got 10 using a button and a textfield with mygrid.getSelectedRowId();
Any ideas?
Thank you in advance,
Andreas.

What is the colIndex value in the problematic case?

The code itself looks valid, but be sure that you have defined IDs for the columns ( grid.setColumnIds ), without that getColIndexById will return -1 for unknown id which will crash the cells() call

I have set the column ids correctly (there is also a column id by the name “neighbor”) and I tested to make sure that colIndex variable gets the correct value. I may have to point out that I currently use grid v3.0

The same functionality must work in 3.0 - it is the standard API

Maybe

  • you are using dyn. loading mode ( not all data loaded to client side and forEachRow fails )
  • you have empty non-unique ids for some rows, which breaks forEachRow functionality

I am using dynamic loading, is there a way to know when loading data is complete, like a callback function? I want to call my code everytime the grid loads data

In case of dyn. loading there is no callback, because the idea of dyn. loading - load only visible part of data to client side, so client side dataset is never fully loading in many cases ( it will be fully loaded only when user will scroll through all data )

Instead of forEachRow you can use onRowCreated event, which called each time when new row loaded and rendered in grid. From it you can make the same check - as result it will be executed for all loaded rows ( and if additional data will be requested from server side, your code will run through that additional rows as well. )

Exaclty what I was looking for, thank you Stanislav.
I thought that everytime the grid got a response from the server (on scroll) a function was called.