This question is locked. New answers and comments are not allowed.
Hi,
I am unable to use Ajax binding with a DataTable, I've followed all the online examples and keep getting the error:
"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions"
Here is my View:
and the Controller Action/View Model:
Paul
I am unable to use Ajax binding with a DataTable, I've followed all the online examples and keep getting the error:
"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions"
Here is my View:
@(Html.Telerik().Grid(Model.Data) .Name("LoanPurposesGrid") .ToolBar(commands => commands.Insert()) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("_select", "ProgramManagement") .Insert("AddFinancingElementGrid", "ProgramManagement") .Update("UpdateFinancingElementGrid", "ProgramManagement") .Delete("DeleteFinancingElementGrid", "ProgramManagement"); }) .Columns(columns => { columns.LoadSettings(Model.Columns as IEnumerable<GridColumnSettings>); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.BareImage); commands.Delete().ButtonType(GridButtonType.BareImage); }).Width(110).Title("Action"); }) .EnableCustomBinding(true) .Footer(false) .Sortable())and the Controller Action/View Model:
public class TestModel { public DataTable Data { get; set; } public IEnumerable<GridColumnSettings> Columns { get; set; } } public GridColumnSettings[] columns() { GridColumnSettings[] columns = new[] { new GridColumnSettings { Member = "Id", Width = "130px", Title="Id"}, new GridColumnSettings { Member="Number", Title="Number", Width = "130px"}, new GridColumnSettings { Member = "Description", Width = "130px", Title="Description"}, }; return columns; } public ActionResult Index() { DataTable table = new DataTable(); table.Columns.Add("Id"); table.Columns.Add("Number"); table.Columns.Add("Description"); DataRow row = table.NewRow(); row[0] = 1; row[1] = 2; row[2] = "Description 1"; table.Rows.Add(row); row = table.NewRow(); row[0] = 2; row[1] = 3; row[2] = "Description 2"; table.Rows.Add(row); TestModel model = new TestModel() { Data = table, Columns = columns() }; return View(model); }Paul