Categories | Question details Back To List | ||
dhtmlxtree smartRefreshBranch behaviour problem I think I must be doing something incorrectly as smartRefreshBranch closes tree folders whereas smartRefreshItem does not. 1) smartRefreshItem works ok ie If I add/ delete a node from my server it is only reflected in the tree when I clck on the immediate parent of that node. eg smartRefreshItem(itemId,"xml/tree.php" 2) smartRefreshBranch behaviour problem I dont know if this works - if I clck on a parent folder it closes the child folder ie I have to click on the immediate parent of that node added/deleted to see the change. eg smartRefreshBranch(itemId,"xml/tree.php" Answer posted by Support on May 20, 2009 10:23 Both methods uses the same updating logic, but while smartRefreshItem expects that xml will contain info only about one level of tree, smartRefreshBranch expects that incoming data will contain all childs on all levels from current point. If you have next levels item1 - item 2 - item 3 and on selection of item1, smartRefreshBranch called, and return xml only for item2 - component will destroy all items which exists in tree, but missed in XML - which means item3 will be deleted to be processed correctly in above case, server side script need to return xml for both item2 and its child node item3 Answer posted by Stephen on May 21, 2009 06:57 [A] I did not explain myself very well in my post. The behaviour of my tree is 1. click on a node to select it 2. double click on a node to edit it 3 click on the '-' or '+' icons to close or open a folder (sub tree). But if I call smartRefreshBranch then the behaviour of the tree changes. If I now do (1) above ie click on a node then the action is as (3) ie clicking on a node not only selects it, it now opens/closes the folder (sub tree). smartRefreshItem does not do this. All I do is rename Item to Branch to change the call. [B] From your answer I can see my call smartRefreshBranch(itemId,"xml/tree.php"). is wrong. And from your answer it must be because "xml/tree.php" does create XML that contains all childs on all levels. However it is used in tree.loadXML("xml/tree.php"). I would have thought this was ok as loadXML appears to repeated call tree.php for each level. Are you saying I need something different? (btw tree.php came from dhtmlx20_tutorial.zip directoryTree.php.) Answer posted by Support on May 21, 2009 09:22 >>(btw tree.php came from dhtmlx20_tutorial.zip directoryTree.php.) This file is designed for dyn. loading - so it returns only one branch of the tree by single request, so it can be used with "smartRefreshItem" command, for "smartRefreshBranch" command you need to have some kind of script which returns not single level but all levels from item in question. By the way, the name "smartRefreshItem" is a bit confusing, this method refreshes not single item but all children of item in question - which is desired use-case in most cases, the smartRefreshBranch method updates all children, and children of children and so further. >>ie clicking on a node not only selects it, it now opens/closes the folder The usage of refresh methods must not affect functionality of tree, but in case of smartRefreshBranch and php which returns only single level of tree - child-not-loaded-yet state may be reset for children of updated item, which cause unwanted closing|opening on selection. >>And from your answer it must be because "xml/tree.php" does create XML that contains all childs on all levels. However it is used in smartRefreshItem - xml must return only single level of tree ( directoryTree.php works in such mode ) smartRefreshBranch - xml must return all descendant of item in question, on all levels of tree If you need to update just one level of tree - use smartRefreshItem smartRefreshBranch has sense if you want to update whole tree for example, and it will need a different php file, which will return all hierarchy, not a single level. Answer posted by Stephen on May 26, 2009 06:51 >>(btw tree.php came from dhtmlx20_tutorial.zip directoryTree.php.) This file is designed for dyn. loading... >>for "smartRefreshBranch" command you need to have some kind of script which returns not single level but all levels from item in question Do you have an example script? I cant see one in the samples. >>ie clicking on a node not only selects it, it now opens/closes the folder Sorry that was me - I was playing with smart item display. Answer posted by Support on May 26, 2009 10:02 Sample of smartRefreshBranch usage sent by email |