Mediator
Mediator

Reputation: 15388

How do deep filtering in kendoui HierarchicalDataSource?

I have simple treeview with hierarchical data in 3 level in deep.

I load all data on load page. I have simple schema

model: {
    hasChildren: function (item) {
        return item.items && item.items.length > 0;
    },
    id: "id",
    children: "items"
}

Default filter work only on first level, How can I change this logic?

Upvotes: 1

Views: 996

Answers (1)

OnaBai
OnaBai

Reputation: 40887

Not sure what you mean but default filter does not work only on first level. Check the following example where I show anything that starts with "F". You will see that it shows the root and node in the first level. What it does not show are nodes bellow a node that does not meet the condition of starting with "F" but that's what I would have expected.

var inlineDefault = new kendo.data.HierarchicalDataSource({
  data: [
    {
      text: "Full",
      items: [
        { 
          text: "Furniture", 
          items: [
            { text: "Tables & Chairs" },
            { text: "Sofas" },
            { text: "Occasional Furniture" }
          ]
        },
        { 
          text: "Decor", 
          items: [
            { text: "Bed Linen" },
            { text: "Curtains & Blinds" },
            { text: "Carpets" }
          ]
        }
      ]
    }
  ],
  filter: { field: "text", operator: "startswith", value: "F" }

});

$("#treeview-left").kendoTreeView({
  dataSource: inlineDefault
});
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2014.2.1008/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.1008/js/kendo.all.min.js"></script>

<div id="treeview-left"></div>

Upvotes: 1

Related Questions