This is a migrated thread and some comments may be shown as answers.

strange behavior after re-ordering a node's children

4 Answers 70 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 11 May 2010, 09:12 PM
I have created some functionality that allows a user to re-order the children of a node in a treeview control. Here is how it works:
  • The user right-clicks a node to launch a context menu
  • The user selects "Reorder subordinates" from the context menu
  • A RadWindow launches a "dialog box" that contains and unordered list of the children of the clicked item. Each list item has a check box next to it. The user can select the children they want to re-order and use "Up" and "Down" buttons to move them up and down the list. When the user clicks "Commit Changes" button, a comma seperated list of the items, in their new order is returned to the parent page, which does an AJAX callback to the database and updates the order of the children.
  • On the client side (javascript), after the AJAX callback, the following code runs, and updates the parent node in the treeview:
    //get the treeview, and get the node
    treeview.trackChanges();
    node.collapse();
    node.get_nodes().clear();
    node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.WebService);
    node.expand();
    treeview.commitChanges();

All these works without error (YEAH!) and the child nodes are re-loaded in the newly edited order. But, if I click the parent node that has just had its children re-ordered, the children suddenly revert back to their original order. They are not being reloaded from the database (the database now has them in the correct order so, they would re-load in the correct order anyway, if that were true). So, it seems like there is a legacy of the old order being stored in memory, and that is somehow being re-applied.

I tried putting a "treeview.commitChanges()" command directly after the line that clears the child nodes, and another "treeview.trackChanges()" command directly after that but, that had no effect.

How can I ensure that I have truly cleared the memory of the child nodes in the old order?

Thanks for any help you can provide.

4 Answers, 1 is accepted

Sort by
0
Roger
Top achievements
Rank 1
answered on 13 May 2010, 08:19 PM
After doing a lot of testing on this, I have some other observations about the current state of the functionality:

Now, if a node has five children: A, B, C, D, E and they are re-ordered, using the RadWindow functionality, to E, A, B, C, D everything looks find after the RadWindow is closed. My code to reorder the nodes in the treeview works just fine. If I then click the parent node (select it) then the old children, in their original order, are re-loaded IN ADDITION TO the newly ordered children so, you get:
E, A, B, C, D, A, B, C, D, E

What is going on?

Another note: If, instead of left-clicking the parent node to select it, after the children have been reordered, I right-click the parent and choose the Reorder Subordinates items again from the menu, when the RadWindow is made visible, the tree node reloads behind it, rendering the same results...

Once the old nodes are added back, nothing will get rid of them...collapsing and expanding the node does nothing. The user has to reload the page to see the nodes displayed correctly.

Again...no server code is running to make this happen.

I have created javascript functions to capture all the client side events that are provided by the RadTreeview control, and none of them seems to be the cause.

Any advice about how I can further debug this would really be appreciated.

Thanks.
0
Nikolay Tsenkov
Telerik team
answered on 14 May 2010, 09:24 AM
Hi Roger,

It sounds pretty strange, indeed!
Could you please open a support ticket and send us a simple project that reproduces this issue? This is the best way to analyze and solve this problem!

Thanks.


Regards,
Nikolay Tsenkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Roger
Top achievements
Rank 1
answered on 14 May 2010, 08:04 PM
In the process of trying to make an example application that would create the same error, I figured out what the problem was. I am sure that is often the case.

During the OnClientContextMenuItemClicking event, when I launched the RadWindow that was my "dialog box" for re-ordering the children, I should have cancelled the postback to the server. The code was launching the RadWindow then, in the background, it was making a trip to the server. I think that loaded the pre-reorder state of the node's children into some memory. Then, after the child nodes were re-ordered, and the parent node was clicked, another trip to the server is made and, I think, the pre-reorder state of the parent node was somehow being picked up again.

So, preventing the needless trip to the server solved the problem. It is working as it should now.

Thanks for your response.
0
Nikolay Tsenkov
Telerik team
answered on 17 May 2010, 08:27 AM
Hi Roger,

Great!
In this case I shouldn't get any credit - you did it on your own!

But If there is something else you can always count on our support.


Regards,
Nikolay Tsenkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Roger
Top achievements
Rank 1
Answers by
Roger
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or