角树中的多项选择

问题描述

我正在尝试覆盖shift +单击以选择树中的多个节点。我的操作方法与本教程中的方法相同

import { ITreeOptions,TreeNode,TREE_ACTIONS,KEYS,IActionMapping} from 'angular-tree-component';
actionMapping: IActionMapping = {
    mouse: {
      click: (tree,node,$event) => {
        $event.shiftKey
          ? TREE_ACTIONS.TOGGLE_SELECTED_MULTI(tree,$event)
          : TREE_ACTIONS.TOGGLE_SELECTED(tree,$event)
      }
    }
  };
@ViewChild('tree') tree: any;
 treeOptions: ITreeOptions = {
    actionMapping:this.actionMapping,getChildren: this.getChildren.bind(this),usevirtualscroll: true,nodeHeight: 22
 };
<tree-root #tree [nodes]="nodes" [focused]="true" [options]="treeOptions" (updateData)="treeUpdate()" (moveNode)="onMoveNode($event)">
...
</tree-root>

但它不起作用,属性'TOGGLE_SELECTED_MULTI'在TREE_ACTIONS上不存在。

解决方法

const actionMapping:IActionMapping = {
  mouse: {
    click: TREE_ACTIONS.TOGGLE_ACTIVE_MULTI
  }
};

public options = { 
    actionMapping
  };

和 HTML 一样

<tree-root [nodes]="nodes" [options]="options"></tree-root>