Revision history [back]

click to hide/show revision 1
initial version

asked 2020-08-18 18:03:34 +0800

AnnaU gravatar image AnnaU

Can't disable checkbox parent

I have a tree (DefaultTreeModel<treenode<suorightdto>>) of checkboxes:

<tabpanel width="100%" height="100%" style="border: 0; padding: 0;" vflex="1" hflex="1">
                            <tree id="rightTree" model="@load(vm.adminModTree)" vflex="1"  >
                                <template name="model">
                                    <treeitem open="true">
                                        <treerow>
                                            <treecell>
                                              <checkbox label="${each.data.name}"
                                               onCheck="@command('checkRight', 
                                                node=each, checked=self.isChecked())"
                                  checked="@load(vm.selectedItem.suoRights.contains(each.data))" 
                                                          disabled="@load(vm.isDisabled(each))"/> 
                                            </treecell>
                                        </treerow>
                                    </treeitem>
                                </template>
                            </tree>
                        </tabpanel>

This is method "checkRight":

@Command("checkRight")
public void checkRight(@BindingParam("node") TreeNode<SuoRightDTO> node, @BindingParam("checked") boolean checked) {
    if (checked) {
       getSelectedItem().getSuoRights().add(node.getData());
        if(node.getParent()!=null){
            getSelectedItem().getSuoRights().add(node.getParent().getData());
            if(node.getParent().getParent()!=adminModTree.getRoot().getData()){
                getSelectedItem().getSuoRights().add(node.getParent().getParent().getData());
            }

            BindUtils.postNotifyChange(null, null, this, "adminModTree");
         }
    } else {
        getSelectedItem().getSuoRights().remove(node.getData());
    }
}

I need to disable a parent of a child if it checked. Now it it's just checked without disable.

Can't disable checkbox parent

I have a tree (DefaultTreeModel<treenode<suorightdto>>) of checkboxes:

<tabpanel width="100%" height="100%" style="border: 0; padding: 0;" vflex="1" hflex="1">
                            <tree id="rightTree" model="@load(vm.adminModTree)" vflex="1"  >
                                <template name="model">
                                    <treeitem open="true">
                                        <treerow>
                                            <treecell>
                                              <checkbox label="${each.data.name}"
                                               onCheck="@command('checkRight', 
                                                node=each, checked=self.isChecked())"
                                  checked="@load(vm.selectedItem.suoRights.contains(each.data))" 
                                                          disabled="@load(vm.isDisabled(each))"/> 
                                            </treecell>
                                        </treerow>
                                    </treeitem>
                                </template>
                            </tree>
                        </tabpanel>

This is method "checkRight":

@Command("checkRight")
public void checkRight(@BindingParam("node") TreeNode<SuoRightDTO> node, @BindingParam("checked") boolean checked) {
    if (checked) {
       getSelectedItem().getSuoRights().add(node.getData());
        if(node.getParent()!=null){
            getSelectedItem().getSuoRights().add(node.getParent().getData());
            if(node.getParent().getParent()!=adminModTree.getRoot().getData()){
                getSelectedItem().getSuoRights().add(node.getParent().getParent().getData());
            }

            BindUtils.postNotifyChange(null, null, this, "adminModTree");
         }
    } else {
        getSelectedItem().getSuoRights().remove(node.getData());
    }
}

I need to disable a parent of a child if it that checked. Now it it's just checked without disable.

Can't disable checkbox parent

I have a tree (DefaultTreeModel<treenode<suorightdto>>) of checkboxes:

<tabpanel width="100%" height="100%" style="border: 0; padding: 0;" vflex="1" hflex="1">
   <tree id="rightTree" model="@load(vm.adminModTree)" vflex="1"  >
     <template name="model">
       <treeitem open="true">
         <treerow>
           <treecell>
             <checkbox label="${each.data.name}"
                 onCheck="@command('checkRight',  node=each,  checked=self.isChecked())"
                 checked="@load(vm.selectedItem.suoRights.contains(each.data))" 
                 disabled="@load(vm.isDisabled(each))"/> 
           </treecell>
         </treerow>
       </treeitem>
     </template>
   </tree>
 </tabpanel>

This is method "checkRight":

@Command("checkRight")
public void checkRight(@BindingParam("node") TreeNode<SuoRightDTO> node, @BindingParam("checked") boolean checked) {
    if (checked) {
       getSelectedItem().getSuoRights().add(node.getData());
        if(node.getParent()!=null){
            getSelectedItem().getSuoRights().add(node.getParent().getData());
            if(node.getParent().getParent()!=adminModTree.getRoot().getData()){
                getSelectedItem().getSuoRights().add(node.getParent().getParent().getData());
            }

            BindUtils.postNotifyChange(null, null, this, "adminModTree");
         }
    } else {
        getSelectedItem().getSuoRights().remove(node.getData());
    }
}

I need to disable a parent of a child that checked. Now it it's just checked without disable.

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More