I have a dynamic model below is the cshtml code, is line editing possible with dynamic model ?
@(Html.Kendo().Grid<dynamic>()
.Name(
"requestCapacity"
)
.Columns(columns =>
{
foreach
(var c
in
Model)
{
if
(c.Equals(
"Week Starting"
))
columns.Template(@<text> </text>).ClientTemplate(@
"<span class='k-widget k-datepicker' style='width: 150px;'><span class='k-picker-wrap k-state-default'><input id='datepicker' style='width: 100%;' data-role='datepicker' type='text' class='k-input' role='combobox' aria-expanded='false' aria-owns='datepicker_dateview' aria-disabled='false' aria-readonly='false' aria-activedescendant='270cfa37-b189-46a8-b0ea-857df06f84ab_cell_selected'><span unselectable='on' class='k-select' role='button' aria-controls='datepicker_dateview'><span unselectable='on' class='k-icon k-i-calendar'>select</span></span></span></span>"
).Width(150).Title(c.Key);
else
columns.Template(@<text>c</text>).Title(c.Key);
}
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
}
)
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.HtmlAttributes(
new
{ style =
"height:auto;width:85%;align:center;margin:0 auto"
})
.Pageable()
.ToolBar(toolbar => toolbar.Create().Text(
"Add"
))
.Sortable()
.Scrollable().EnableCustomBinding(
true
)
.DataSource(dataSource => dataSource
.Ajax().Model(model =>model.Id(
"ID"
)
)
.PageSize(10)
.Events(events => events.Error(
"error_handler"
))
.Create(update => update.Action(
"EditingInline_Update"
,
"RequestCapacity"
,
new
{testing=
"#=dataItem#"
}).Type(HttpVerbs.Post))
.Read(read => read.Action(
"PopulateRequest"
,
"RequestCapacity"
).Type(HttpVerbs.Post))
.Update(update => update.Action(
"EditingInsline_Update"
,
"RequestCapacity"
,
"#=dataItem#"
).Type(HttpVerbs.Post))
.Destroy(update => update.Action(
"EditingInline_Destroy"
,
"Capacity"
))
)
)
controller code.
public
ActionResult RequestCapacityPopUp()<br> {<br> var dynamicBinding =
new
List<
string
>(){
"Week Starting"
};<br>
using
(var dataModel =
new
CapacityPlannerEntities())<br> {<br>
foreach
(var team
in
dataModel.Teams)<br> {<br> dynamicBinding.Add(team.TeamName);<br> }<br> }<br>
return
View(dynamicBinding);<br> }