refreshItems() ignores item's open state when redrawing +/-

Hi there,

I have noted the following behaviour, which seems to be erroneous on the part of Dhtmlx. Assume a tree with the following structure:

ID=1  My mail items
        |
ID=2   (-)--Inbox
        |      |
ID=3    |      |---Subfolder 1
        |      |
ID=4    |      |---Subfolder 2
        |  
ID=5    |---Deleted items

Note that the Inbox folder with ID=2 is expanded and in front of it we see a - sign.

If I make the following call:

_dhtmlxTree.refreshItems(2, "generatexml.php?id=1");

My PHP document will create the following output:

<?xml version="1.0" encoding="UTF-8"?>
<tree id="1">
  <item id="2" text="Inbox" im0="folder_new_16.png" im1="images/folder_new_16.png" im2="images/folder_new_16.png" child="1">
    <userdata name="Class">4</userdata>
  </item>
  <item id="5" text="Deleted items" im0="images/folder_16.png" im1="images/folder_16.png" im2="images/folder_16.png" child="0">
    <userdata name="Class">2</userdata>
  </item>
</tree>

Which updates the tree to:

ID=1  My mail items
        |
ID=2   (+)--Inbox
        |      |
ID=3    |      |---Subfolder 1
        |      |
ID=4    |      |---Subfolder 2
        |  
ID=5    |---Deleted items

Which seems to be erroneous because now the Inbox folder has a + sign in front of it, while it is in an expanded state.

I can get the desired result by omitting the child=“1” attribute in the xml document. The - sign (or the + sign if Inbox happens not to be expanded) is then left unchanged. However, this requires that my PHP code knows if the request is made for the purpose of loadXML() or the autoloader on one hand or refreshItems() on the other hand. Only the latter case should then omit the child=“1” attribute. I believe I can even make such distinction by examining the presence of the ids get parameter.

But…

  • This would require extra logic on the php part, which means every developer will have to implement this without error. I would rather see this solved by Dhtmlx once.
  • More importantly: I believe dhtmlXTree should never display a + sign on an item that is already expanded because it would make the interface inconsistent. Therefor, my preliminary conclusion is that this is a bug.

Dhtmlx, can you comment on this? Do you consider this bug too, will it be addressed and in which version? Also, is my current workaround through the ids parameter valid?

I am using dhtmlxSuite_v30_pro_111031.

Kind regards,

Joost

On a sidenote, I realize that at present my php xml generator produces more items than is necessary. The filter on the ids parameter is not yet implemented.

Actually, I just realized that my suggested workaround, examining the ids parameter does not work. This is for the following reason:

If inbox currently has sub items, then the ids approach will work.

However assume that the inbox currently has no subitems and then code is executed server side that changes the database and inbox now does have subitems. Note that in the data on the server side Inbox has children, but this is not yet reflected on the client.

So, to reflect this on the client side I will call refreshItems() which will include the ids parameter. If I then chose to omit the child=1 parameter then the + sign will never appear.

I could write a whole bunch of code around this to make it work as expected but it seems all that will be unnecessary if dhtmlXTree calls its own getOpenState() method to determine wether to draw a + or a -.

Can you guys fix this?

Regards,

Joost

Appologies to keep going on this, but I just saw something that adds to the severity of this issue.

Once dhtmlXTree erroneously draws a + instead of a -, it also allows it to expand the item. While expanding, dhtmlXTree also invokes the autoloader. The autoloader will then produce the xml for all the subitems, as requested by dhtmlXTree. However, dhtmlXTree had already loaded some of those items before and presto… duplicate items!

That is certainly a bug.

Ok, I’ll keep it at this, looking forward to your reply.

Regards,

Joost

Hi,

please try to use smartRefreshItem that is designed to be used in dynamic trees:

_dhtmlxTree.smartRefreshItem(1, “generatexml.php?id=1”);

or just:

_dhtmlxTree.smartRefreshItem(1);

here is the sample:

dhtmlxTree/samples/12_loading_processing_data/11_pro_smart_refresh.html

Hi Alexandra,

That seems to work fine. Thank you.

Joost

Thx to alexandra :wink:

Hello again
We’ve tested the sample you sent with official libraries - the issue doesn’t repeat.
I can specify, where did you download the files you use?