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

Adding additional data on ajax grid post not using js function name string

0 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 24 Sep 2012, 04:03 PM
I have a grid which is using ajax to retrieve data using the "read" method. This requires additional data to be posted to the controller. This works good using a javascript function to send the additional data. And their are many examples of this being done. But due to requirements I would like to create the actual javascript function inside the "Data" call instead of specifying the string for the javascript function name. Based on the intellisense I think this is possible but not sure of the syntax. 

So the example below shows what works (Read #1) and what I want to do instead (Read #2).

 @(Html.Kendo().Grid<Tabs.Viewer.UI.WebViewer.Models.MyModel>()
 .Name("Grid")
 .Columns(columns => {       
                                   columns.Bound(p => p.Email).Title("column1");
                                   columns.Bound(p => p.Description).Title("column2");
.DataSource(dataSource => dataSource 
                                         .Ajax()
                                         .Model(model => model.Id(p => p.myId))
  // Read #1 This works fine but do not want to specify the method name
                                         .Read(read => read.Action("PopulateAlertGrid", "ProductAlert").Data("onAdditionalProductAlertGridData"))
 // Read #2 Note: I want to add the actual js code instead of the above line.
                                         .Read(read => read.Action("PopulateAlertGrid", "ProductAlert").Data(function myMethod(){...})
))

So can someone share the syntax to put the js code in the data call or if this is possible?

Thanks, Dan

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Share this question
or