Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by raj on Jun 05, 2008 04:24
open dhtmlx forum
selection of new added row

hi,

I am using smartrendering to load the grid, and my requirement to add new row at the end of the last row,
and that row should be selected after adding new row,
so I am using the following code to add new row:

//This function adds a new row at the end grid
function addNewRow()
{
var columnCount = mygrid.getColumnCount();
var newrow=new Array(columnCount);
newrow[columnCount-1]="N";

var id = "NEWID"+(new Date()).valueOf();

mygrid.addRow(id,newrow,-1);
mygrid.selectRow(mygrid.getRowIndex(id));
mygrid.showRow(id);

}

Using smart rendering, I tried to add new row and to be selected after creating it, but the row is not selected automatically after creating it, when I scroll down to end of the last row, it is showing that the new row was added.

So can u please help me to select the newly added row after creating it?

/Thanks
Raj

Answer posted by Support on Jun 05, 2008 08:30
Please try to use
    grid.selectRowById
instead of
    grid.selectRow

mygrid.addRow(id,newrow,-1);
mygrid.selectRow(id);
mygrid.showRow(id);

While in normal state both commands are equal, in smart rendering mode the ID based commands is more reliable ( because the ID is constant, while index position is inconsistent )