Categories | Question details Back To List | ||
Tree problem when adding child node Hi guys, The debug file really helped. I can now see what's going wrong so can also asked the right questions. I'm creating a child node, returning an ID from the server and then try to open the new child node to retrieve info back from the server on that new node. This is what I'm getting...
<data> <action type='insert' sid='169' tid='24939'/> </data>
SID is the node that I'm attaching the child node to and that adds to the DB fine but then here's the problem. For some reason the add child node repeats itself again and again adding another child but to the newly created node. The other issue is that the new child node ID is incorrect, how in my code do I specifiy my new child node to have the tid variable as shown above? The debug script that shows when I click on the new child node shows that I have a uid='1246583992929' and id='1_1246583992929' or something like that as I can't copy and paste from the alert box. Here's my code that calls the add child node which is new_next_node which is on an onClick event in the tree... <script> Thanks for your help!
Answer posted by Alex (support) on Mar 12, 2009 09:02 Hello, could you, please, provide the direct link to the page with problem? (you also can send this information to support@dhtmlx.com) Answer posted by Support on Mar 12, 2009 09:47 >> tree.insertNewChild(tree_node,0," The parameters of insertNewChild are - parentId - new item id If they are correct in above snippet, than you are using incorrect ID for newly created item, 0 already reserved for virtual root item, so you can use other, unique value here. >>For some reason the add child node repeats itself You have "CHILD" attribute set for newly added item, which result in "branch" creating, which may trigger loading extra data from linked server side script. While it is a correct syntax - be sure that it is desired behavior in your case. ( incorrect response from server side script, may cause above problem ) >>and id='1_1246583992929' component automatically generates unique ID in such way when item with duplicate ID found. Please be sure that you have unique IDs for all elements. Answer posted by Dale on Mar 12, 2009 09:55 OK great, how do I pull back the new ID that is created in the XML that is generated from the below code <data> <action type='insert' sid='169' tid='24939'/> </data> I thought that the below code would be wrong but as I couldn't find any documentation on how to return my new ID I assumed it automatically replace the 0 value. The new ID is generated after I have fired my new_next_node(). Are you saying I should generate my ID then fire my function? tree.insertNewChild(tree_node,0,"New location",0,0,0,0,"SELECT,CALL,TOP,CHILD"); Unfortunately this is on a local intranet so I cannot get you access to the pages. Answer posted by Dale on Mar 12, 2009 09:59 Just to clarify... 1). I click on 'add location' in my tree which then adds a child node to the parent ID 2). This generates my <data> XML and calls a stored procedure which return the tid (the new location's ID from my DB) I thought at that point the tree would use the tid in the XML generated to replace the 0 ID that I fired originally. Answer posted by Support on Mar 12, 2009 11:18 >>use the tid in the XML generated to replace the 0 ID that I fired originally This is correct in normal case, but ID == 0 already used by virtual root item, so you need to use some other value as temporary ID. Answer posted by Dale on Mar 12, 2009 12:41 I changed the number to something else and it just used that number and did not replace it with the new ID in the tid field. Any other suggestions to replace this temporary ID with the one i've created in the XML? Answer posted by Alex (support) on Mar 13, 2009 03:56 Please, check that xml returns the desired values. For example if you add the following node tree.insertNewChild(parent_id,'temp_id','New item'); The xml must be: <data> Locally this approach correctly works. So, if the problem still persists, please provide the direct link to the problematic page. Answer posted by Dale on Mar 13, 2009 11:09 Just to clarify then. My code which is tree.insertNewChild(tree_node,0,"New location",0,0,0,0,"SELECT,CALL,TOP,CHILD"); should actually read tree_node = 169 which is returned from my JS function tree.insertNewChild(tree_node,'temp_id',"New location",0,0,0,0,"SELECT,TOP,CHILD"); Right I must be missing something obvious because I tried it and it carried through id=temp_id and never replace it with the tid from the XML which was 24657 or somthing like that. I've uploaded to my production server now so please have a look - much appreciated. I've put the debug on. http://www.ethossolution.co.uk/gateway/secure/portal_tree.html Thanks!
Answer posted by Dale on Mar 13, 2009 11:24 Oh last thing, please go into Admin > Demo Company Ltd > Add Location, to test the add child thing. Answer posted by Alex (support) on Mar 16, 2009 03:00 Hello, Probably there is the following issue in your server-side script: The dataprocessor sends, for example, following parameters: !nativeeditor_status =inserted But the server-side script returns: <action type='insert' sid='169' tid='24970'/> sid is the tr_id parameter (not tr_pid parent id) Answer posted by Dale on Mar 16, 2009 10:50 That cracked it, thanks! |