Insert new item in tree

Can we get the id of the newly created node on doing insertNewItem ?


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;

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.


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 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.