How to get kendo listview data item count

Rick S picture Rick S · Aug 16, 2013 · Viewed 8.2k times · Source

I have a kendo listview that is bound to a datasource. When the user clicks an Add button I call $("#arealistview").data("kendoMobileListView").prepend([newItem]), which adds a new item to the beginning of the list.

How can I get a count of the items in the listview?

Answer

Atanas Korchev picture Atanas Korchev · Aug 17, 2013

The total method of the data source should return that:

var total = $("#arealistview").data("kendoMobileListView").dataSource.total();

Or you can get the length of the array returned by the data method:

var data = $("#arealistview").data("kendoMobileListView").dataSource.data();
var total = data.length;