Filtering a ListView does not refresh the list

2 posts, 0 answers
  1. dabiel
    dabiel avatar
    1 posts
    Member since:
    Jul 2013

    Posted 23 Jul 2013 Link to this post

    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

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 24 Jul 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top