I have a ListView and Pager bound to a DataSource that gets its data from a remote url (i.e. using transport.read). For the sake of this example we'll call the objects returned by the url and bound to the DataSource, "DataSourceObjects". It works as expected.
However, the ListView exists on a webpage that uses ajax to update other elements on the webpage (Call #1). When those other elements update, the ListView must update and display data from a different page of the DataSource, based on the new values of those elements. This means a call to DataSource.page() and thus another round-trip to the server (Call #2). I'd like to combine Call #1 and Call #2 into one call. I should be able to do this by sending the DataSourceObjects for the new page during Call#1 and then manually updating the DataSource with those new DataSourceObjects, bypassing the DataSource.page() call and bypassing transport.read(). I'd also need to manually update the page being displayed by the Pager attached to the DataSource, again without it making another call to the server.
I've done a lot of looking around to see how this could be accomplished but haven't found an example of what I'm describing. I've gotten so far as to update the data being displayed by the ListView by calling DataSource.data(DataSourceObjects), but I can't get the Pager to display the right page number. I read a suggestion to try DataSource.query({ page: NewPageNumber }) but that doesn't seem to work.
Can you tell me how to accomplish what I've described? Thanks.
UPDATE:
I was able to use the get the .query() call working as described here (http://www.kendoui.com/forums/framework/data-source/setiing-pagesize-dynamically-causing-read-.aspx). Calling manuallyUpdateDataSource() seems to update the data as I want it to, but the .query() line causes a server hit, which I don't want.
However, the ListView exists on a webpage that uses ajax to update other elements on the webpage (Call #1). When those other elements update, the ListView must update and display data from a different page of the DataSource, based on the new values of those elements. This means a call to DataSource.page() and thus another round-trip to the server (Call #2). I'd like to combine Call #1 and Call #2 into one call. I should be able to do this by sending the DataSourceObjects for the new page during Call#1 and then manually updating the DataSource with those new DataSourceObjects, bypassing the DataSource.page() call and bypassing transport.read(). I'd also need to manually update the page being displayed by the Pager attached to the DataSource, again without it making another call to the server.
I've done a lot of looking around to see how this could be accomplished but haven't found an example of what I'm describing. I've gotten so far as to update the data being displayed by the ListView by calling DataSource.data(DataSourceObjects), but I can't get the Pager to display the right page number. I read a suggestion to try DataSource.query({ page: NewPageNumber }) but that doesn't seem to work.
Can you tell me how to accomplish what I've described? Thanks.
UPDATE:
I was able to use the get the .query() call working as described here (http://www.kendoui.com/forums/framework/data-source/setiing-pagesize-dynamically-causing-read-.aspx). Calling manuallyUpdateDataSource() seems to update the data as I want it to, but the .query() line causes a server hit, which I don't want.
var
myDataSource =
new
kendo.data.DataSource({
pageSize: 10,
serverPaging:
true
,
transport: {
read: {
url:
'http://mydataurl/'
,
headers: {
'X-Requested-With'
:
'XMLHttpRequest'
}
},
parameterMap:
function
(data, type) {
// Code for parameterMap.
}
},
schema: {
data:
'Data'
,
total:
'Total'
},
});
function
manuallyUpdateDataSource(dataSourceObjects) {
myDataSource.data(dataSourceObjects);
myDataSource.query({ pageSize: 10, page: 3 }); // setting to page 3 just for testing.
}