Creating a new row with parameters from selected row?

Hello!

I’m working with the newest dhtmlxgrid version and everything is working excellently its just great :slight_smile:

My Grid is fetching records from a MySQL database, displaying the data in a sortable and filterable grid, saving data all-at-once via processor back into the DB which is UTF-8 just like the grid itself.

Now the idea is to make a link which creates a new row with a couple of values from the currently selected row. So when a row is selected, clicking the link will make a new row and uses 4 values from the selected row. It sounds simple but i can’t figure it out, i’m testing for days now and it doesnt work. In the Database the first column is auto_increment, so it should insert NOTHING.

this code:

<a href="javascript:void(mygrid.addRow(mygrid.uid(),\'\',\'\',\'\',mygrid.cells(mygrid.getSelectedRowId(),2).getValue()))">use selected row as a pattern and insert a new row</a>

doesnt work at all.

i know in this board are a lot of JS geeks which could help me, and i hope this is possible in some kind :slight_smile:

any ideas?

greetings

Nick

You may create a row and fill it with the values from a needed one with copyRowContent() method:
docs.dhtmlx.com/doku.php?id=dhtm … rowcontent

Thanks for the reply!

I tried both, and then i saw the error in the code so i made this:

javascript:void(mygrid.addRow(mygrid.uid(), (\',\' + mygrid.cells(mygrid.getSelectedRowId(),1).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),2).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),3).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),4).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),5).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),6).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),7).getValue() + \',\' + mygrid.cells(mygrid.getSelectedRowId(),8).getValue()), (mygrid.getRowIndex(mygrid.getSelectedRowId()) + 1)));

And it works fine :slight_smile:

Forget to mention in the previous post, it’s escaped for PHP.