I suggest you ...

Pass server side variables to Ajax() datasource binding for Kendo Grid

Current, if one were to use the Kendo Grid in UI for MVC, there's no way to bind the datasource using Ajax binding and specify server side parameters to the read function in the controller.

In many cases, the read function on the controller side will use a primary key to do a select statement to get particular details of a model to render.

This is relatively simple to keep track of on the javascript side and server side when there's just one grid, as we can use a hidden input and always update it's value from the model.

However, when we have an array of grids, and an array of primary keys for the grids, this is very difficult to keep track of which read function corresponds to which grid.

The only solution is to generate multiple javascript read functions with the primary key baked into the names and in the bodies of the functions on the server side, which is ugly and not optimal for security.

@foreach(var modelID in Model.ModelIDs)

var readFunction = "function modelStatsReadData_" + modelID + "()";
<text>
@readFunction
{
return {
modelID: @modelID
}
}
</text>
} @*end foreach loop*@

@foreach(var model in Model.Models)
{
....

.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(m => m.ID);
})
.Read(read => read.Action("FlowPlanDetails_Read", "SubmitFlow").Data("flowPlanReadData_" + @model.D))

}

This is solvable if we do server side binding for the datasource, as we can pass route values. But that is an entirely different implementation and we shouldn't have choose Ajax() versus Server() binding based on how functional the API is.

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Fred WangFred Wang shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base