This is a migrated thread and some comments may be shown as answers.

Filter is only applied to the 1st hierarchy of the TreeView

5 Answers 565 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 09 Jan 2013, 06:20 PM
Hi all!

I'm using the feature described here http://demos.kendoui.com/web/treeview/api.html to filter treeview items by text. 

I already have all nodes loaded (they are not all expanded), but when I apply the filter using the code above, it does not work.

treeview.dataSource.filter({
field: "text",
operator: "contains",
value: filterText
});

Example 

  • Item aa
  • Item bb
    • Item xx
    • Item yy

if search text is "xx", no items are displayed. Instead I would like to have the following result:

  • Item bb
    • Item xx
But if your search text is "aa", "bb" or some string similar to root item texts ... the nodes are displayed

Does anyone knows how to make the filter applying for all nodes?

BTW! I'm using MVC and the last build of Kendo

Thanks!

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 10 Jan 2013, 08:23 AM
Hello Alberto,

See the following StackOverflow thread for a solution.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Otto Neff
Top achievements
Rank 2
answered on 12 Nov 2014, 09:13 AM
If you need more than just "findByText" try this

that.nodeFilter = { logic: "or", filters: [] };
that.nodeFilter.filters.push({ field: "hidden", operator: "eq", value: false });
tree.element.find(".k-in").each(function () {
    var dItem = tree.dataItem($(this).closest("li"));
    dItem.hidden = false;
    if (dItem["VALUE"].toLowerCase().indexOf(searchTerm) != -1 ||
        dItem["TEXT"].toLowerCase().indexOf(searchTerm) != -1) {
        that.nodeFilter.filters.push({ field: "VALUE", operator: "eq", value: dItem["VALUE"] })
        while (dItem.parentNode()) {
            dItem = dItem.parentNode();
            dItem.hidden = false;
            that.nodeFilter.filters.push({ field: "VALUE", operator: "eq", value: dItem["VALUE"] })
        }
    } else {
        dItem.hidden = true;
    }
});
tree.dataSource.filter(that.nodeFilter);
tree.element.find(".k-in").each(function () {
    var node = $(this).closest("li");
    var dataItem = tree.dataItem(node);
    if (dataItem.hidden) {
        tree.remove(node);
    }
});
0
Marian
Top achievements
Rank 1
answered on 13 Nov 2015, 04:19 PM
Hi, How can I provide all levels filtering when I'm using server-side operations?
0
Marian
Top achievements
Rank 1
answered on 13 Nov 2015, 05:16 PM
I can see that data.ToDataSourceResult(request); finds correct record but it does not get displayed in the treeview
0
Alex Gyoshev
Telerik team
answered on 17 Nov 2015, 11:40 AM

Hello Marian,

I am afraid that this feature is not supported by the TreeView widget at this time. Please open separate threads when the question deviates from the original post.

Regards,
Alex Gyoshev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Alberto
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Otto Neff
Top achievements
Rank 2
Marian
Top achievements
Rank 1
Share this question
or