Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/docs/en-US/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ You can drag and drop Tree nodes by adding a `draggable` attribute.
| --------------- | ---------------------------------------- | ---------------------------------------- |
| filter | filter all tree nodes, filtered nodes will be hidden | Accept a parameter which will be used as first parameter for filter-node-method |
| updateKeyChildren | set new data to node, only works when `node-key` is assigned | (key, data) Accept two parameters: 1. key of node 2. new data |
| getCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes | Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
| getCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes | (leafOnly, includeHalfChecked) Accept two boolean type parameters: 1. default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. 2. default value is `false`. If the parameter is `true`, the return value contains halfchecked nodes |
| setCheckedNodes | set certain nodes to be checked, only works when `node-key` is assigned | an array of nodes to be checked |
| getCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of node's keys | (leafOnly) Accept a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
| setCheckedKeys | set certain nodes to be checked, only works when `node-key` is assigned | (keys, leafOnly) Accept two parameters: 1. an array of node's keys to be checked 2. a boolean type parameter whose default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. |
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/es/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ Puede arrastrar y soltar nodos de Tree añadiendo un atributo `draggable` .
| ----------------- | ---------------------------------------- | ---------------------------------------- |
| filter | Filtra los nodos del árbol, los nodos filtrados estarán ocultos | Acepta un parámetro que será usado como primer parámetro para filter-node-method |
| updateKeyChildren | Asocia un nuevo dato al nodo, solo funciona si `node-key` está asignado | (key, data)Acepta dos parámetros: 1. clave del nodo 2. nuevo dato |
| getCheckedNodes | Si los nodos puede ser seleccionado (`show-checkbox` es `true`), devuelve el array de nodos seleccionados | Acepta un booleano cuyo valor por defecto es `false` |
| getCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes | (leafOnly, includeHalfChecked) Accept two boolean type parameters: 1. default value is `false`. If the parameter is `true`, it only returns the currently selected array of sub-nodes. 2. default value is `false`. If the parameter is `true`, the return value contains halfchecked nodes |
| setCheckedNodes | Establece algunos nodos como seleccionados, solo funciona cuando `node-key` está asignado | Un array de nodos a seleccionar |
| getCheckedKeys | Si los nodos pueden ser seleccionados (`show-checkbox` es `true`), devuelve un array con las claves de los nodos seleccionados | (leafOnly) Acepta un booleano que por defecto es `false`. |
| setCheckedKeys | Establece algunos nodos como seleccionados, solo si `node-key` está asignado | (keys, leafOnly) Acepta dos parametros: 1. un array de claves 2. un booleano cuyo valor por defecto es `false`. Si el parámetro es `true`, solo devuelve los nodos seleccionados |
Expand Down
2 changes: 1 addition & 1 deletion examples/docs/zh-CN/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@
| --------------- | ---------------------------------------- | ---------------------------------------- |
| filter | 对树节点进行筛选操作 | 接收一个任意类型的参数,该参数会在 filter-node-method 中作为第一个参数 |
| updateKeyChildren | 通过 keys 设置节点子元素,使用此方法必须设置 node-key 属性 | (key, data) 接收两个参数,1. 节点 key 2. 节点数据的数组 |
| getCheckedNodes | 若节点可被选择(即 `show-checkbox` 为 `true`),则返回目前被选中的节点所组成的数组 | (leafOnly) 接收一个 boolean 类型的参数,若为 `true` 则仅返回被选中的叶子节点,默认值为 `false` |
| getCheckedNodes | 若节点可被选择(即 `show-checkbox` 为 `true`),则返回目前被选中的节点所组成的数组 | (leafOnly, includeHalfChecked) 接收两个 boolean 类型的参数,1. 是否只是叶子节点,默认值为 `false` 2. 是否包含半选节点,默认值为 `false` |
| setCheckedNodes | 设置目前勾选的节点,使用此方法必须设置 node-key 属性 | (nodes) 接收勾选节点数据的数组 |
| getCheckedKeys | 若节点可被选择(即 `show-checkbox` 为 `true`),则返回目前被选中的节点的 key 所组成的数组 | (leafOnly) 接收一个 boolean 类型的参数,若为 `true` 则仅返回被选中的叶子节点的 keys,默认值为 `false` |
| setCheckedKeys | 通过 keys 设置目前勾选的节点,使用此方法必须设置 node-key 属性 | (keys, leafOnly) 接收两个参数,1. 勾选节点的 key 的数组 2. boolean 类型的参数,若为 `true` 则仅设置叶子节点的选中状态,默认值为 `false` |
Expand Down
4 changes: 2 additions & 2 deletions packages/tree/src/model/tree-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ export default class TreeStore {
delete this.nodesMap[node.key];
}

getCheckedNodes(leafOnly = false) {
getCheckedNodes(leafOnly = false, includeHalfChecked = false) {
const checkedNodes = [];
const traverse = function(node) {
const childNodes = node.root ? node.root.childNodes : node.childNodes;

childNodes.forEach((child) => {
if (child.checked && (!leafOnly || (leafOnly && child.isLeaf))) {
if ((child.checked || (includeHalfChecked && child.indeterminate)) && (!leafOnly || (leafOnly && child.isLeaf))) {
checkedNodes.push(child.data);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/tree/src/tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
return path.reverse();
},

getCheckedNodes(leafOnly) {
return this.store.getCheckedNodes(leafOnly);
getCheckedNodes(leafOnly, includeHalfChecked) {
return this.store.getCheckedNodes(leafOnly, includeHalfChecked);
},

getCheckedKeys(leafOnly) {
Expand Down
7 changes: 4 additions & 3 deletions types/tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ export declare class ElTree extends ElementUIComponent {
/**
* If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes
*
* @param subnodes If the `subnodes` is `true`, it only returns the currently selected array of sub-nodes
* @param leafOnly If the `leafOnly` is `true`, it only returns the currently selected array of sub-nodes
* @param includeHalfChecked If the `includeHalfChecked` is `true`, the return value contains halfchecked nodes
*/
getCheckedNodes (leafOnly?: boolean): TreeNode[]
getCheckedNodes (leafOnly?: boolean, includeHalfChecked?: boolean): TreeNode[]

/**
* Set certain nodes to be checked. Only works when `node-key` is assigned
Expand All @@ -148,7 +149,7 @@ export declare class ElTree extends ElementUIComponent {
/**
* If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes' keys
*
* @param subnodes If the `subnodes` is `true`, it only returns the currently selected array of sub-nodes
* @param leafOnly If the `leafOnly` is `true`, it only returns the currently selected array of sub-nodes
*/
getCheckedKeys (leafOnly?: boolean): any[]

Expand Down