This is a migrated thread and some comments may be shown as answers.
ListView Filter
4 Answers 38 Views
This is a migrated thread and some comments may be shown as answers.
Pushpender
Top achievements
Rank 1
Pushpender asked on 28 Mar 2014, 12:43 PM
Is there any way to get the count of number of items matching the filter criteria in a ListView?

4 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 28 Mar 2014, 01:14 PM
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!
 
0
Pushpender
Top achievements
Rank 1
answered on 01 Apr 2014, 05:36 AM
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.
0
Pushpender
Top achievements
Rank 1
answered on 01 Apr 2014, 06:09 AM
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');
            }           
}
0
Accepted
Kiril Nikolov
Telerik team
answered on 01 Apr 2014, 07:51 AM
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!
 
Asked by
Pushpender
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Pushpender
Top achievements
Rank 1
Share this question
or