Problem with Checked status of RadTreeNode.

5 posts, 0 answers
  1. Murilo
    Murilo avatar
    10 posts
    Member since:
    Feb 2011

    Posted 01 Feb 2011 Link to this post

    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
  2. Murilo
    Murilo avatar
    10 posts
    Member since:
    Feb 2011

    Posted 07 Feb 2011 Link to this post

    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.
  3. Murilo
    Murilo avatar
    10 posts
    Member since:
    Feb 2011

    Posted 08 Feb 2011 Link to this post

    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
  4. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 14 Feb 2011 Link to this post

    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.
  5. Murilo
    Murilo avatar
    10 posts
    Member since:
    Feb 2011

    Posted 18 Feb 2011 Link to this post

    I did forget about the trackChanges and commitChanges, my problem was solved using attributes, thanks.
Back to Top