ListView Filter

5 posts, 1 answers
  1. Pushpender
    Pushpender avatar
    5 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 Link to this post

    Is there any way to get the count of number of items matching the filter criteria in a ListView?
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 28 Mar 2014 Link to this post

    Hi Pushpender,

    You can use the view() of the dataSource, that will return only the items, that are left after filtering, and you can get its length property. I have created an example, showing a possible implementation:

    http://jsbin.com/jotarija/1/edit

    Regards,
    Kiril Nikolov
    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
  4. Pushpender
    Pushpender avatar
    5 posts
    Member since:
    Mar 2014

    Posted 01 Apr 2014 Link to this post

    Hey thanks for the quick reply. That does gives me a count of items in the ListView.
    Can we call an event when the ListView is filtered based on the search criteria? In the example provided, it was on the button click. Whereas, I want to bind it to the ListView Filter Event.
  5. Pushpender
    Pushpender avatar
    5 posts
    Member since:
    Mar 2014

    Posted 01 Apr 2014 in reply to Kiril Nikolov Link to this post

    I implemented it in "DataBind" event of ListView. Is this approach correct?

    dataBound: function(e) {
                var contactDataSource = this.dataSource;
                if(contactDataSource.view().length == 0){
                   navigator.notification.alert("No result found", function () {}, "", 'OK');
                }           
    }
  6. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 01 Apr 2014 Link to this post

    Hi Pushpender,

    Using dataBound event is perfectly fine, so you can go ahead and use it as the event will be fired every time the ListView is filtered.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready