updating a grid item disables onAfterSelect

If I update the contents of a grid, the “onAfterSelect” event no longer fires on that row.

$$('my_grid').attachEvent('onAfterSelect',function(id)
{
  updateItem(id);
}

function updateItem(id)
{
  var data = { /* new data goes here */ };
  $$('my_grid').update(id,data);
  $$('my_grid').refresh(id);
}

The data in the grid gets updated, the line refreshes with the new data, but I can no longer select that line. onAfterSelect continues to work on all other, un-updated, grid lines.

Is there something else I need to do?

update() method completely changes item properties, all of them. Therefore, you should set all properties including “id”. If you are not sure that the data object contains all the properties, you should use something like so:

var data = {…};
var item = $$(‘my_grid’).item(id);
dhx.extend(item,data,true);
$$(‘my_grid’).refresh(id);