radtreeview with checkbox

2 posts, 1 answers
  1. Federik
    Federik avatar
    3 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2012 Link to this post

    Hi,

    I need a radtreeview with checkboxes which allow to check a child only if its parent is checked.

    Thanks & regards
    Federik
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Jun 2012 Link to this post

    Hi Federik,

    Try the following Javascript to achieve your scenario.

    JS:
    <script type="text/javascript">
     function OnClientNodeChecking(sender, args)
      {
        if ((args.get_node().get_level() != 0) && (!args.get_node().get_parent().get_checked()))
        {
            args.set_cancel(true);
        }
        if (args.get_node().get_checked())
        {
            var nodes = args.get_node().get_allNodes();
            for (var i = 0; i < nodes.length; i++)
          {
            nodes[i].uncheck();
          }
        }
      }
    </script>

    Thanks,
    Princy.
Back to Top