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

Filtering a ListView does not refresh the list

1 Answer 207 Views
ListView
This is a migrated thread and some comments may be shown as answers.
dabiel
Top achievements
Rank 1
dabiel asked on 23 Jul 2013, 05:59 PM
What I want is to list all books in a ListView. Then, clicking a button related with a category, I want to filter them. All books are loaded in the client side (there are not many). Server is not called for filtering.  

When I press a button, the following function is called:

function filterByCategory() {
 var list = $("#reportlistview").data("kendoListView");
  list.dataSource.filter({
field: "Category",
operator: "contains",
value: "xx"
});
}

I expected that the ListView only shows items with Category=xx, but the listview does not change. It continuous showing all books.

The ListView is created with:

@(Html.Kendo().ListView<Books>(Model)
.Name("reportlistview")
.TagName("div")
.ClientTemplateId("template")
.Selectable()



What am I doing wrong?

Thank you

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 24 Jul 2013, 12:21 PM
Hi Dabiel,


Since all the data is passed on the initial load of the ListView, I would suggest you to set the ServerOperation of the dataSource to false to specify that the filtering should be performed on the client side.
E.g.
@(Html.Kendo().ListView<Books>(Model)
.Name("reportlistview")
.TagName("div")
.ClientTemplateId("template")
.Selectable()
.DataSource(dataSource => {
    dataSource.ServerOperation(false);
})

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView
Asked by
dabiel
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or