Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Zedr on Apr 01, 2009 05:31
open dhtmlx forum
insert new item in tree

Can we get the id of the newly created node on doing insertNewItem ?
Answer posted by Alex (supprot) on Apr 01, 2009 06:40

When you call  insertNewItem, you must pass the id of the new item into this method. 

But if it is necessary, something as follows can be used:

var n = tree.insertNewItem(...);

var id = n.id;

Answer posted by Zedr on Apr 01, 2009 06:51
It gives me a long number like 1238593868886. I want the item_id of the new item created from database. Please advise what to do to get such no.
Thanks.

Answer posted by Alex (supprot) on Apr 01, 2009 08:10

Probably you use DataProcessor.

In this case the new id is set automatically. The new id is the "tid" attribute which is defined in the <action> tag. Please, see the sample: in the tree package dhtmlxTree/samples/dataprocessor/pro_save_data.html

Also please take a look at the article dhtmlxTree/doc/guide.html#dataprocessor.

In common case you can change item id using changeItemId(itemId,newItemId) method.