Select parent, all childern checked

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ericahlstrom
    Indigo Rose Customer
    • Jun 2004
    • 62

    Select parent, all childern checked

    I am using the Tree object and I am trying to make it so that if you select the check box of the parent node that all the children within that node would be checked.

    Of course if you unchecked the parent all the check box's would be unchecked as well.

    Any help would be appreciated.
  • ericahlstrom
    Indigo Rose Customer
    • Jun 2004
    • 62

    #2
    Any help please?

    Comment

    • andulek
      Forum Member
      • Feb 2009
      • 30

      #3
      It is really simple, im going to give you the main idea. Put in your project a NEW tree object with DEFAULT objects:

      Item 1
      Sub Item 1
      Sub Item 2

      then open it's script editor, and put this code "ON CHECK" event:

      Code:
      tblProp = {};
      if (e_NodeIndex == "1" and e_Checked == true) then
      	tblProp.Checked = true;
      	Tree.SetNode("Tree1", "1.1", tblProp);
      	Tree.SetNode("Tree1", "1.2", tblProp);
      elseif (e_NodeIndex == "1" and e_Checked == false) then
      	tblProp.Checked = false;
      	Tree.SetNode("Tree1", "1.1", tblProp);
      	Tree.SetNode("Tree1", "1.2", tblProp);
      end
      hope this helps.

      Comment

      • ericahlstrom
        Indigo Rose Customer
        • Jun 2004
        • 62

        #4
        Thanks, this helps. I have been away from AMS for some months and am trying to get myself back up to speed.

        Comment

        • ericahlstrom
          Indigo Rose Customer
          • Jun 2004
          • 62

          #5
          My code

          By the way, this is the code I am using and works great. I have two parent nodes with an unknown number of children.



          tblProp = {};

          -- Get the child count of 'Tree1'
          ChildCount = Tree.GetChildCount("search", "1");

          -- Get the child count of 'Tree2'
          ChildCount2 = Tree.GetChildCount("search", "2");

          -- Check if main index checked
          if (e_NodeIndex == "1") and (e_Checked == true) then
          for count = 1, ChildCount, 1 do
          tblProp.Checked = true;
          Tree.SetNode("search", "1."..count, tblProp);
          end

          -- Check if main index not checked
          elseif (e_NodeIndex == "1") and (e_Checked == false) then
          for count = 1, ChildCount, 1 do
          tblProp.Checked = false;
          Tree.SetNode("search", "1."..count, tblProp);
          end
          end


          -- Check if second index checked
          if (e_NodeIndex == "2") and (e_Checked == true) then
          for count = 1, ChildCount2, 1 do
          tblProp.Checked = true;
          Tree.SetNode("search", "2."..count, tblProp);
          end

          -- Check if second index not checked
          elseif (e_NodeIndex == "2") and (e_Checked == false) then
          for count = 1, ChildCount2, 1 do
          tblProp.Checked = false;
          Tree.SetNode("search", "2."..count, tblProp);
          end
          end

          Comment

          • andulek
            Forum Member
            • Feb 2009
            • 30

            #6
            yeah, thats probably the best solution, i was too lazy to write it all, anyway i'm glad you resolved your problem anyway

            Comment

            Working...
            X