Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by John Hughes on Sep 04, 2007 17:15
open dhtmlx forum
Possible to add a row at a specific position in tree?

I see that addRow lets you put a new row under a specific parent in a tree grid. However, it ignores the position argument in that case, and seems to always put the new row at the end of the parent's children. Is there any way to control where it appears? I'll need it to appear in different spots at different times, so the nicest thing would be for it NOT to ignore the position I give it, but to actually add it as, say, the 3rd child if I give it a 2 for ind. Would this at least be an easy hack?
Answer posted by Stanislav on Sep 04, 2007 19:33
Currently the "index" property is worable, but it mean global index through tree, not the index in branch , so it hardly usable
But starting from dhtmlxTreeGrid 1.4 you can use
    grid.addRowBefore(new_id,text,sibl_id,img,child);
    grid.addRowAfter(new_id,text,sibl_id,img,child);
where sibl_id - id of item relative to which new one will be positioned

which allows to add new row after or before any existing row in treeGrid