0

I am unable to find any way to disable checkbox node using angular tree component. There is no option to mark the tree disabled so that the checkboxes that appear alongwith th etree data should be disabled. Please suggest

1 Answer 1

0

Disabling the node can be done by actionMapping inside options attribute https://angular2-tree.readme.io/v1.2.0/docs/options. Here click event of mouse can be overwritten.

<Tree  [nodes]="nodes"  [options]="treeOptions"></Tree>

In my tree data I kept an attribute isSelectable on each node, which is true|false. In case of true i proceed selecting the node otherwise it does not do anything. Here are full options that I am passing to the tree component.

public options: ITreeOptions = {
    isExpandedField: 'expanded',
    idField: 'uuid',
    getChildren: this.getChildren.bind(this),
    actionMapping: {
      mouse: {
        click: (tree, node, $event) => {
          if ( node.data.isSelectable ) {
            this.isNodeSelected.emit(node.data);
            this.alreadySelected = true;
            this.preSelected.tree = tree;
            this.preSelected.node = node;
            this.preSelected.event = $event;
            TREE_ACTIONS.ACTIVATE(this.preSelected.tree, this.preSelected.node, this.preSelected.event);
          }
        }
      }
    },
    nodeHeight: 23,
    allowDrag: (node) => {
      return false;
    },
    allowDrop: (node) => {
      return false;
    }
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.