How to provide Read parameters

3 posts, 0 answers
  1. Eric
    Eric avatar
    24 posts
    Member since:
    Dec 2010

    Posted 28 Apr 2020 Link to this post

    I have the data source defined using Read for my Kendo MVC grid.  Every time that the data is refreshed, I want to include some data from the browser.  I don't care if  I have to use params or query string or whatever, but I need to be able to specify values to include in the ajax call to the server and those values will change as the user interacts with the page.  How do I get those values included in the ajax call?  There must be a standard way to do this, since it is hard to imagine a grid without fields on the screen controlling the grid data, but I cannot find any examples of this in the demos.

     

    .DataSource(dataBinding => dataBinding.Ajax()
             .Read(read => read.Action("_CustomBinding", "Members"))
    )
  2. Eric
    Eric avatar
    24 posts
    Member since:
    Dec 2010

    Posted 28 Apr 2020 Link to this post

    I found another post that addresses this, but I do wish there had been an example of this in the demos.

    Also, this solution states that you have to alter your Controller signature to include the additional parameters, but you don't actually.  Instead, you can leave just the DataSourceRequest parameter and access all of the other data through the Request.Params collection.

    https://www.telerik.com/forums/pass-additional-parameters-to-read-ajax-datasource-method---mvc

     

    .Read(read => read.Action("Products_Read""Grid").Data("additionalInfo"))

     

    function additionalInfo() {
        return {
            name: "test",
            id: 2
        }
    }


  3. Tsvetomir
    Admin
    Tsvetomir avatar
    837 posts

    Posted 30 Apr 2020 Link to this post

    Hi Eric,

    I am happy to hear that you have managed to resolve the case on your own. 

    Indeed, the only demo that has the additional parameter sent is the Hierarchy. As it is the only one that requires an additional parameter. It is sent via the route values option:

    https://demos.telerik.com/aspnet-mvc/grid/hierarchy

    Thank you for pointing out that the request.Params have not been used in an example and does not contain a stand-alone article. I will log it in our tracking system as a to-do item. 

    In case any additional questions arise, let me know.

     

    Regards,
    Tsvetomir
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top