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

Problem with Checked status of RadTreeNode.

4 Answers 108 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Murilo
Top achievements
Rank 1
Murilo asked on 01 Feb 2011, 01:57 PM
Hi, i'm having some kind of trouble while i try to use the Checked property of RadTreeNode, i want to use this property but i don't want to show the checkbox to my user.

This is how my code looks like:

<telerik:RadTreeView OnClientNodeClicked="ClientNodeClicked" CheckBoxes="false"runat="Server" ID="tvwMenuItens"></telerik:RadTreeView>

I tried to set CheckBoxes to true and it worked but i don't want my users to see the checkbox.

Here's how i'm changing the Checked property:

function ClientNodeClicked(sender, eventArgs) {
              var node = eventArgs.get_node();
              var toolBar = $find('<%= tlbSecurityProfile.ClientID %>');
              var saveButton = toolBar.findItemByValue('Save');
 
              if (node.get_text() != null && node.get_text() != '') {
                  if (node.get_value() != null && node.get_value() != '') {
                      if (saveButton.get_enabled()) {
                          if (node.get_checked()) {
                              node.set_checked(false);
                              node.set_imageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_No_Access.png") %>');
                              node.set_selectedImageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_No_Access.png") %>');
                          }
                          else {
                              node.set_checked(true);
                              node.set_imageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_Has_Access.png") %>');
                              node.set_selectedImageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_Has_Access.png") %>');
                          }
                      }
                  }
              }
          }

I also tried to user Node.Attributes but unfortunately when i tried to get the values from Attributes at server side they were exactly the same as they were in the time of the databind.

Here's how i changed the Attributes from the node:

function ClientNodeClicked(sender, eventArgs) {
              var node = eventArgs.get_node();
              var toolBar = $find('<%= tlbSecurityProfile.ClientID %>');
              var saveButton = toolBar.findItemByValue('Save');
 
              if (node.get_text() != null && node.get_text() != '') {
                  if (node.get_value() != null && node.get_value() != '') {
                      if (saveButton.get_enabled()) {
                          var attributes = node.get_attributes();
 
                          if (attributes.getAttribute("Checked") == "true") {
                              attributes.setAttribute("Checked", "false");
                              node.set_imageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_No_Access.png") %>');
                              node.set_selectedImageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_No_Access.png") %>');
                          }
                          else {
                              attributes.setAttribute("Checked", "true");
                              node.set_imageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_Has_Access.png") %>');
                              node.set_selectedImageUrl('<%=Page.ResolveUrl("~/Images/TreeView/TreeView_Has_Access.png") %>');
                          }
                  }
              }
          }


That's all, thanks

4 Answers, 1 is accepted

Sort by
0
Murilo
Top achievements
Rank 1
answered on 07 Feb 2011, 11:46 AM
any ideas for a solution? I just need to store my attribute somewhere so I can change it on client-side and get it on server-side in the postback, thanks for your attention.
0
Murilo
Top achievements
Rank 1
answered on 08 Feb 2011, 07:22 PM
I forgot to post some information:

Visual Studio 2010.
.Net Framework: 4.0
Telerik.Web.UI: 2010.3.1109.40
Browser: Mozzila Firefox
Browser Version: 3.6.13
OS: Windows XP
0
Dimitar Terziev
Telerik team
answered on 14 Feb 2011, 02:37 PM
Hello Murilo,

My suggestion is to use custom attributes instead this checkboxes if you don't want to the user to see them.
You could name the custom attribute "checked state" or whatever name is more appropriate and assign value to it. Then you will get this value in  ClientNodeClicked event and perform the necessary actions.
You are getting the same value on server-side because you are not persisting changes made on the client-side and thus the treeview is only "remembering" the values assigned when it was databinded.

To persist changes made to a specific node or to the whole treeview you should use the trackChanges and commitChanges methods. More information you could find here.

I hope this solution is suitable for you.
 
Greetings,
Dimitar Terziev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Murilo
Top achievements
Rank 1
answered on 18 Feb 2011, 11:42 AM
I did forget about the trackChanges and commitChanges, my problem was solved using attributes, thanks.
Tags
TreeView
Asked by
Murilo
Top achievements
Rank 1
Answers by
Murilo
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or