• Filter tree node by specific attribute key name and value

    Example

    import { filterTreeByName } from "tree-handle-lib";
    const tree = [
    {
    key: "1",
    title: "A",
    children: [
    {
    key: "11",
    title: "AA",
    },
    {
    key: "12",
    title: "AB",
    },
    ],
    },
    {
    title: "B",
    children: [
    {
    key: "21",
    title: "BA",
    },
    {
    key: "22",
    title: "BB",
    },
    ],
    },
    ];
    const _result = filterTreeByName(tree, "A", true);
    // [
    // {
    // key: "1",
    // title: "A",
    // children: [],
    // },
    // ];

    Parameters

    • node: TNode

      the root node of the tree,can be a single node or an array of nodes

    • filterValue: string

      the filter value

    • isExactMatch: boolean = false

      is exact match filter

    • isIgnoreCase: boolean = true
    • titleName: string = TITLE_NAME

      the attribute key name to filter,default is TITLE_NAME='title'

    • childrenName: string = CHILDREN_NAME

      the child key name of the child node in the tree structure,default value is CHILDREN_NAME='children'

    Returns TNode

Generated using TypeDoc