AddRow through link in dhtmlxTreeGrid

Hello,



I added the library







to be able to use columntype “link” in our celldata





The link should execute a function or code to add a row right under the row from which we pressed the ‘add row’ link



I tried with :



add^javascript:mygrid.addRow((new Date()).valueOf(),[‘new row’,‘text’,‘text’,1,0],0)



add^javascript:mygrid.addRow((new Date()).valueOf(),[‘new row’,‘text’,‘text’,1,0],0);mygrid.refreshGrid()



add^javascript:mygrid.addRow((new Date()).valueOf(),[‘new row’,‘text’,‘text’,1,0],0)^_self





I’m new to JS programming, so I wonder what’s the best technique to achieve this.



Thanks,

Yves



The common approach is
add^javascript:my_add()^_self
and somewhere in js code define

function my_add(){
mygrid.addRow(mygrid.uid(),[‘new row’,‘text’,‘text’,1,0],0);
}

Also, you can use any plain column type instead of link and assign the same functionality through event

grid.attachEvent(“onRowSelect”,function(id,ind){ //for each click
if (ind==5) // if action cell clicked ( 5 is just a sample of index )
my_add();
return true;
})