This is a migrated thread and some comments may be shown as answers.

Passing additional parameters to DataSource and persisting them

1 Answer 1901 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
CM
Top achievements
Rank 1
CM asked on 22 Jul 2014, 01:08 AM
Hello,

I understand how the DataSource.read() functionality works; I send a JavaScript plain object and the parameters and values are sent to the server. That all works well. I also understand how the data object works under the read transport; that won't work in this instance, because the ViewModel that has the data I need upon search isn't created until after the DataSource itself. I don't want to use require.js if I don't have to :)

But, what if I have a DataSource that has server paging (I use the skip and take parameters on the server to process the request) and I send a plain object when I read? How do I persist the query parameters after I go to the next page in a Data Grid?

For instance:

*** DataSource ***

var rfqDataSource = new kendo.data.DataSource({
  schema: { model: { id: "RFQ" }, data: "RfqQuotes", total: "total" },
  transport: { read: { url: window.rfqQuotePath, dataType: "json" } },
  serverPaging: true,
  pageSize: 15
});

*** Call to read the datasource after a search button is clicked ***

rfqDataSource.read({ customer: rfqModel.customer, startDate: rfqModel.startDate });

The Grid that is bound to the DataSource filters correctly, but as soon as I go to the next page, the read parameters are lost. Better yet, if I'm on page two of the Grid before I do a search, and do the search, the Grid may show no results at all depending on how many pages of actual data are returned.

So, I want to be able to send parameters to the API and persist those parameters until I search again or clear the search parameters.






1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 23 Jul 2014, 01:17 PM
Hello Christopher,

This could be achieved by specifying the additional parameters in the transport.read.data option.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
CM
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or