dhtmlxgrid new row after cell tab

Hi,

I’m trying to create a new row inside my grid when i’m in last row and cell , moving with the
“tab” button between the cells.
so when i click the tab button in the last row and cell i want the new row to be created and that the focus will be inside the first cell , so it can be edited.

how can I do this?

Thanks.

You can use “onEditCell” event, check if you are closing last cell editor, add new row and open editor of first cell in the row.
To open editor of the cell you may use selectCell() method docs.dhtmlx.com/doku.php?id=dhtm … selectcell

It’s better to call this method with delay
window.setTimeout(function(){
mygrid.selectCel(…
},1);

Thanks for your help,
when i try to write after the row was added , i can wirte in the focused cell , but when i move to another cell in that row , the cell text is deleted like it’s not been written.

what should i do in order for the text to be saved inside the row cells?

Thanks again.

To be more specific - this is my code:

function doOnCellEdit(stage, rowId, cellInd) {
if (stage == 2)
{
var num = mygrid.getRowsNum() - 1;
var last_row_num = mygrid.getRowIndex(rowId);
var last_cell_index = mygrid.getColumnsNum() - 2;
var sIndex = mygrid.getSelectedCellIndex();
if(num == last_row_num && sIndex == last_cell_index)
{
mygrid.addRow(last_row_num+1, ["","","","","","","","",""]);
try
{
window.setTimeout(function(){ mygrid.selectCell(last_row_num+1,0,false,true,false)} ,1);
}
catch(err)
{
alert(2);
}
return true;
}
}
}
the situation i described before is hapening in all of the cells except from the last one, where the new row is added to the grid , i that cell i can see the add text value i entered.

Please advice

Thanks .

Correct code is:

[code]if (stage == 2)
{
var num = mygrid.getRowsNum() - 1;
var last_row_num = mygrid.getRowIndex(rowId);
var last_cell_index = mygrid.getColumnsNum() - 2;
var sIndex = mygrid.getSelectedCellIndex();
if(num == last_row_num && sIndex == last_cell_index)
{
mygrid.addRow(last_row_num+1, ["","","","","","","","",""]);
try
{
window.setTimeout(function(){ mygrid.selectCell(last_row_num+1,0,false,true,false)} ,1);
}
catch(err)
{
alert(2);
}
return true;
}

return true;<<<
}[/code]