Limited max count when checking the checkbox

2 posts, 1 answers
  1. Tommy
    Tommy avatar
    10 posts
    Member since:
    Dec 2008

    Posted 17 Mar 2009 Link to this post

    Hi Team,
        I have set the checkbox value is true also can checked succeed,but I want to limit the max checked count in my treeview.
    Can you give me a hand?  thank .

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Mar 2009 Link to this post

    Hello Tommy,

    I guess you want to cancel the TreeNode checking if a particular count reached. If that the case, you can try the following client side code. Attach function to the OnClientNodeChecking event of RadTreeView.

    JavaScript:
    <script type="text/javascript"
    function OnClientNodeChecking(sender, args) 
         var tree = $find("<%= RadTreeView1.ClientID %>"); 
         var checkedNodes = tree.get_checkedNodes(); 
         if(!args.get_node().get_checked()) 
         { 
             if((checkedNodes.length)>2) 
             { 
                alert ("Max limit reached, Cannot check the node"); 
                args.set_cancel(true); 
             } 
         }      
    </script> 

    Thanks,
    Shinu.
Back to Top