Hi,
at the moment I am converting the old Telerik MVC tool to Kendo MVC for one of our portals.
now I have an issue with a dynamic table, not always all fields are the same and I can't get it to work correctly.
my grid looks like this
@(Html.Kendo().Grid(Model.DefaultView) .Name("Grid") .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("LoadData", "AutorisatieMatrix")) .Update(read => read.Action("_SaveBatchEditing", "AutorisatieMatrix")) .Model(model => model.Id("ProgramFunction")) ) .Sortable() .Editable(editing => editing.Mode(GridEditMode.InCell)) .ToolBar(commands => { commands.Save(); }) .Columns(columns => { columns.Bound("Id").Visible(false); foreach (System.Data.DataColumn dcol in Model.Columns) { if (dcol.ColumnName != "Id") { if (dcol.ColumnName == "ProgramFunction") columns.Bound("ProgramFunction") .EditorTemplateName("_ReadOnlyValue") .ClientTemplate("#=ProgramFunction#") .Title("Programmafunctie"); else { columns.Bound(dcol.ColumnName) .EditorTemplateName("_PermissionEditor") .ClientTemplate(boo(this, "#=" + dcol.ColumnName + "#").ToHtmlString()) .Title(dcol.Caption) ; } } } })
where I go through all colums specified in the model.
and the header gets created as it should.
In the controller in the Index I create an empby DataTable so the Model knows which colums to use.
public ActionResult Index() { var tbl = CreateNewDataTable(); var model = tbl; return View(tbl); }which seems to work fine.
Then In the loadData DataRequest I generate this same DataTable fill it, add a dynamic wrapper to include "Data" in the json
Convert is to Json and return the Content.
