Passing additional parameters to DataSource and persisting them

2 posts, 0 answers
  1. CM
    CM avatar
    12 posts
    Member since:
    Nov 2012

    Posted 21 Jul 2014 Link to this post

    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.






  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 23 Jul 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top