This issue is related to another form post, but slightly different regarding maintaining state of the tree view nodes changed by client side code across post back.
I have four nodes w/Check boxes
A
B
C
D
When A is clicked, if it is checked, it will disable and uncheck every other node. If A is unchecked it will re-enable all other nodes.
What I have found is that if I check B, and then check A, post back, I get my expected result - only A checked with all others disabled and unchecked.
Now, if I uncheck A (which re-enables everything), on the next post back all the other nodes are once again disabled. As if the enable/disable did not persist across the post back (yet it did the first time?).
Code below (code behind is empty):
Telerik control version is 2008.03.1314.35
I have four nodes w/Check boxes
A
B
C
D
When A is clicked, if it is checked, it will disable and uncheck every other node. If A is unchecked it will re-enable all other nodes.
What I have found is that if I check B, and then check A, post back, I get my expected result - only A checked with all others disabled and unchecked.
Now, if I uncheck A (which re-enables everything), on the next post back all the other nodes are once again disabled. As if the enable/disable did not persist across the post back (yet it did the first time?).
Code below (code behind is empty):
| function TVOnNodeChecked(sender, e) | |
| { | |
| var Tree = $find('<%=rtvTest.ClientID %>'); | |
| var TreeNodes = Tree.get_allNodes(); | |
| var ClickedNode = e.get_node(); | |
| if (ClickedNode.get_value() == 1) | |
| { | |
| Tree.trackChanges(); | |
| for (var i = 0; i < TreeNodes.length; i++) | |
| { | |
| var thisNode = TreeNodes[i]; | |
| var thisNodeCB = thisNode.get_checkBoxElement(); | |
| if (thisNode.get_value() != 1) | |
| { | |
| if (ClickedNode.get_checked()) { | |
| thisNode.set_checked(false); | |
| thisNode.set_enabled(false); | |
| } | |
| else | |
| { | |
| thisNode.set_enabled(true); | |
| } | |
| } | |
| } | |
| Tree.commitChanges(); | |
| } | |
| } |
| <asp:Panel ID="pnl1" runat="server"> | |
| <telerik:RadTreeView ID="rtvTest" runat="server" CheckBoxes="true" CheckChildNodes="true" OnClientNodeChecked="TVOnNodeChecked"> | |
| <Nodes> | |
| <telerik:RadTreeNode Text="Node1" Value="1"></telerik:RadTreeNode> | |
| <telerik:RadTreeNode Text="Node2" Value="2"></telerik:RadTreeNode> | |
| <telerik:RadTreeNode Text="Node3" Value="3"></telerik:RadTreeNode> | |
| <telerik:RadTreeNode Text="Node4a" Value="-1"> | |
| </telerik:RadTreeNode> | |
| </Nodes> | |
| </telerik:RadTreeView> | |
| </asp:Panel> | |
| <br /> | |
| <asp:Button ID="btnPostback" runat="server" Text="Go go Postback" /> |
Telerik control version is 2008.03.1314.35