This is a migrated thread and some comments may be shown as answers.
How to provide Read parameters
2 Answers 201 Views
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Veteran
Eric asked on 28 Apr 2020, 06:18 PM

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 Answers, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
Veteran
answered on 28 Apr 2020, 07:50 PM

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
    }
}


0
Tsvetomir
Telerik team
answered on 30 Apr 2020, 05:52 PM

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.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Veteran
Answers by
Eric
Top achievements
Rank 1
Veteran
Tsvetomir
Telerik team
Share this question
or