reside-ic / TreeTables

:deciduous_tree: jQuery plugin extending jquery-datatables to support tree data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search : Display children

sta2m opened this issue · comments

commented

Hi,

On a search, child's parent row are displayed.
But I need to display the childrens too. Ex : If I search CEO, I need all the tree.

Any idea to do that ?

Thanks,

Mickaël.

The only way to do this would be by adding a hidden column containing the row's parent values that you want to search on.

E.g. in the very simple example given:

 const fakeData = [
            {"tt_key": 1, "tt_parent": 0, name: "CEO", salary: 1000000, parent: ""},
            {"tt_key": 2, "tt_parent": 1, name: "CTO", salary: 110000, parent: "CEO"},
            {"tt_key": 3, "tt_parent": 2, name: "Front-end developer", salary: 60000, parent: "CEO, CTO"},
            {"tt_key": 4, "tt_parent": 2, name: "Back-end developer", salary: 65000, parent: "CEO, CTO"},
            {"tt_key": 5, "tt_parent": 1, name: "CFO", salary: 100000, parent: "CEO"}
        ];

 $('#test-table').treeTable({
            "data": fakeData,
            "columns": [
                {
                    "data": "name"
                },
                {
                    "data": "salary",
                    "render": function (data) {
                        return "£" + data;
                    }
                },
                {
                    "data": "parent",
                    "visible": false
                }
            ]
        });