Tree Widget - Parent Checkbox Functionality

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
2 posts • Page 1 of 1
emaddocks
Posts:83
Joined: Tue Sep 04, 2018 12:50 am

Tree Widget - Parent Checkbox Functionality

Post by emaddocks »

The Tree widget provides the ability to add checkboxes to the items in the tree via the 'setCheckable' function. When this is set on the parent and child items in a tree the parent checkbox will check and uncheck the child items. This behaviour is fine if all the child items are enabled. However when one or more child items are disabled, via the 'setEnabled' function, the parent item still checks and unchecks the disabled child items even though they are disabled.

My expectation of this functionality is that the disabled child item should maintain it's state as it is disabled an the user can not click on it to change its state. However when the user clicks the parent they can change the state of the disabled child checkboxes.

Is this a bug or is this the intended functionality of checkboxes in the Tree widget?

Here is the code from the help file with checkboxes added to be able to demonstrate what I have described above:

Code: Select all

main()
{
  //Add three columns
  TREE1.addColumn("SURNAME");
  TREE1.addColumn("FIRST NAME");
  TREE1.addColumn("ADDRESS");
  //Append the "WHOLE NAME" item 
  TREE1.appendItemNC("","WHOLE NAME","WHOLE_NAME");
  //Append three sub items 
  TREE1.appendItemNC("WHOLE NAME","MUELLER","Mueller");
  TREE1.appendItemNC("WHOLE NAME","SCHMIDT","Schmidt");
  TREE1.appendItemNC("WHOLE NAME","KAUFMANN",makeDynString("Kaufmann","Jan","Nebenstr. 100"));
  //Set the texts in the "FIRST NAME" column 
  TREE1.setText("MUELLER", 1, "Maria");
  TREE1.setText("SCHMIDT", 1, "Anna");
  //Set the texts in the "ADDRESS" column 
  TREE1.setText("MUELLER",2, "Hauptstr. 1");
  TREE1.setText("SCHMIDT",2, "Wienerstr. 10");
  //Append three subitems below the "MUELLER" item 
  TREE1.appendItemNC("MUELLER","CHILDREN_M0","CHILDREN");
  TREE1.appendItemNC("MUELLER","CHILDREN_M1","");
  TREE1.appendItemNC("MUELLER","CHILDREN_M2","");
  // Set Checkable
  TREE1.setCheckable("MUELLER", TRUE);
  TREE1.setCheckable("CHILDREN_M0", TRUE);
  TREE1.setCheckable("CHILDREN_M1", TRUE);
  TREE1.setCheckable("CHILDREN_M2", TRUE);
  // Disable one child
  TREE1.setEnabled("CHILDREN_M1", FALSE);
  //Set the texts in the "FIRST NAME" column at the CHILDREN items 
  TREE1.setText("CHILDREN_M1",1,"Klaus");
  TREE1.setText("CHILDREN_M2",1,"Anika");
}

kilianvp
Posts:443
Joined: Fri Jan 16, 2015 10:29 am

Re: Tree Widget - Parent Checkbox Functionality

Post by kilianvp »

From my point of view, this is a bug, because the operator expects this. On the other hand, all other WinCC OA elements behave the same way. As a workaround, you can skip the setCheckable call for the deactivated item. Or check afterwards which items are deactivated.

2 posts • Page 1 of 1