David
David

Reputation: 6111

kendo-ui datasource has data, but view is empty

I'm trying to implement server-side paging on a listView, but it only ever renders the first page. I've done some debugging and what I've found is that in my pager's change event it never called read on the dataSource so I decided to call it manually like this:

App.photoLineupPager = $("#photo-lineup-pager").kendoPager({
    "dataSource": $("#photo-lineup").data("kendoListView").dataSource,
    "change": function (e) {
        e.preventDefault();

        $("#photo-lineup").data("kendoListView").dataSource.read();
    }
}).data("kendoPager");

It now hits the endpoint, returns the expected data, and the loading icon appears where the listView would be. However, the listView isn't displaying any data and in my console if I call:

$("#photo-lineup").data("kendoListView").dataSource.data()

It has values in the returned object, but if I call:

$("#photo-lineup").data("kendoListView").dataSource.view()

There aren't any values in the returned object. And I believe this is why my listView isn't rendering anything past the first page. So I have a couple of questions:

  1. Why is the data populated whereas the view is not?
  2. How do I fix it?

Update So it was literally just a matter of setting the serverPaging property on the dataSource to true. Once I specified that I no longer needed to call the read event in my pager's change event too.

Upvotes: 0

Views: 1189

Answers (1)

bdongus
bdongus

Reputation: 668

I don't know what is running on your server, but the list view expects the data in a property called "data".

For ASP.NET MVC please check this part of the documentation. Whatever you use on the server side, there should be a similar documentation available.

Upvotes: 0

Related Questions