Árbol virtualizado V2beta

Vista del árbol con un rendimiento de desplazamiento rápido para cualquier cantidad de datos

Uso básico

Estructura básica de árbol.

Seleccionable

Usado para la selección de nodos.

WARNING

When using show-checkbox, since check-on-click-leaf is true by default, last tree children's can be checked by clicking their nodes.

Checkbox desactivados

El checkbox de un nodo se puede poner como desactivado.

En el ejemplo, la propiedaddisabled es declarada en defaultProps, y algunos nodos se establecen como disabled: true. Los checkboxes correspondientes son desactivados y no se pueden pinchar.

Desplegado o seleccionado por defecto

Los nodos pueden estar desplegados o seleccionados por defecto.

Utilice default-expanded-keys y default-checked-keys para establecer los nodos desplegados y seleccionados respectivamente.

node-1

Contenido personalizado en los nodos

El contenido de los nodos puede ser personalizado, así que puede añadir iconos y botones a su gusto.

Custom node class 2.9.0

The class of tree nodes can be customized

Custom node icon 2.10.3

You can customize icons for different node states. Tree nodes expose the expanded property and isLeaf property, allowing you to dynamically render different icons based on the node's state: leaf nodes, expanded nodes, or collapsed nodes.

Tree node filtering 2.9.1

The filter-method method can only accept the third parameter after version 2.9.1. Tree nodes can be filtered

Invoque el método filter de la instancia de Tree para filtrar los nodos. Su parámetro es la palabra de filtrado. Note that for it to work, filter-method is required, and its value is the filtering method.

TreeV2 Attributes

NombreDescripciónTipoPor defecto
dataDatos del árbolobject
empty-textTexto a mostrar cuando data es voidstring
propsOpciones de configuraciónobject
highlight-currentSi el nodo actual está resaltadobooleanfalse
expand-on-click-nodeSi expandir o contraer un nodo al pincharlo, si es false solo se hará al pinchar en la flechabooleantrue
check-on-click-nodeSi es false, el nodo sólo se puede marcar o desmarcar haciendo clic en la casilla de verificación.booleanfalse
check-on-click-leaf 2.9.6whether to check or uncheck node when clicking on leaf node (last children).booleantrue
default-expanded-keysArray de claves de los nodos expandidos inicialmenteobject
show-checkboxSi un nodo es seleccionablebooleanfalse
check-strictlyEl estado de selección de un nodo no afecta a sus padres o hijos, cuando show-checkbox es truebooleanfalse
default-checked-keysArray con claves de los nodos seleccionados inicialmenteobject
current-node-keyla clave del nodo inicialmente seleccionadostring / number
filter-methodesta función se ejecutará antes de arrastrar un nodo. si devuelve false, el nodo no puede ser arrastrado.Function
indentIndentación horizontal de los nodos en niveles adyacentes, en pixelesnumber16
iconcustom tree node icon componentstring / Component
item-size 2.2.33altura del nodo de árbol personalizadonumber26
scrollbar-always-on 2.10.4always show scrollbarbooleanfalse

props

AtributosDescripciónTipoPor defecto
valueIdentificador único en todo el árbol para los nodosstringid
labelespecifica qué clave del objeto del nodo se utiliza como labelstringlabel
childrenEspecifica que objeto del nodo se utiliza como subárbolstringchildren
disabledEspecifica si el nodo es una hoja, sólo funciona cuando lazy load está activadostringdisabled
class 2.9.0custom node class namestring / Function

TreeV2 Method

Tree has the following method, which returns the currently selected array of nodes.

MethodDescripciónParámetros
filterfilter all tree nodes, filtered nodes will be hidden(query: string)
getCheckedNodesIf the node can be selected (show-checkbox is true), it returns the currently selected array of nodes(leafOnly: boolean)
getCheckedKeysIf the node can be selected (show-checkbox is true), it returns the currently selected array of node's keys(leafOnly: boolean)
setCheckedKeysset certain nodes to be checked(keys: TreeKey[])
setCheckedset node to be checked or not(key: TreeKey, checked: boolean)
setExpandedKeysset certain nodes to be expanded(keys: TreeKey[])
getHalfCheckedNodesIf the node can be selected (show-checkbox is true), it returns the currently half selected array of nodes
getHalfCheckedKeysIf the node can be selected (show-checkbox is true), it returns the currently half selected array of node's keys
getCurrentKeyreturn the highlight node's key (undefined if no node is highlighted)
getCurrentNodereturn the highlight node's data (undefined if no node is highlighted)
setCurrentKeyset highlighted node by key(key: TreeKey)
getNodeget node by key or data(data: TreeKey | TreeNodeData)
expandNodeexpand specified node(node: TreeNode)
collapseNodecollapse specified node(node: TreeNode)
setDataWhen the data is very large, using reactive data will cause the poor performance, so we provide a way to avoid this situation(data: TreeData)
scrollTo 2.8.0scroll to a given position(offset: number)
scrollToNode 2.8.0scroll to a given tree key with specified scroll strategy(key: TreeKey, strategy?: auto | smart | center | start | end)

TreeV2 Events

NombreDescripciónParameters
node-clicktriggers when a node is clicked(data: TreeNodeData, node: TreeNode, e: MouseEvent)
node-drop 2.8.3triggers when drag something and drop on a node(data: TreeNodeData, node: TreeNode, e: DragEvent)
node-contextmenutriggers when a node is clicked by right button(e: Event, data: TreeNodeData, node: TreeNode)
check-changetriggers when the selected state of the node changes(data: TreeNodeData, checked: boolean)
checktriggers after clicking the checkbox of a node(data: TreeNodeData, info: { checkedKeys: TreeKey[],checkedNodes: TreeData, halfCheckedKeys: TreeKey[], halfCheckedNodes: TreeData,})
current-changetriggers when current node changes(data: TreeNodeData, node: TreeNode)
node-expandtriggers when current node open(data: TreeNodeData, node: TreeNode)
node-collapsetriggers when current node close(data: TreeNodeData, node: TreeNode)

TreeV2 Slots

NameDescription
-Custom content for tree nodes. The scope parameter is { node: TreeNode, data: TreeNodeData }
empty 2.9.0empty you can customize content when data is empty.

Fuente

ComponentesDocumentación

Contribuidores