Here is my code
@(Html.Kendo().Grid<
ServicePROWeb.ServiceProWCFService.GrJscMstr
>()
.Name("gridJobAllocation")
.Columns(columns =>
{
columns.Bound(p => p.gr_sch_date).Title("Date").Format("{0:dd/MMM/yyyy}").Width(120).Locked(true);
columns.Bound(p => p.gr_sch_time).Title("Time").Width(100).Locked(true);
columns.Bound(p => p.gr_sch_assto).Title("Tech").Width(150).Locked(true);
columns.Bound(p => p.gr_ass_time).Title("PL").Width(40).Locked(true).EditorTemplateName("");
columns.Bound(p => p.gr_status)
.EditorTemplateName("_statusDropDownList")
.ClientTemplate("#=gr_status#")
.Title("ST")
.Width(70);
columns.ForeignKey(p => p.gr_status, (System.Collections.IEnumerable)ViewData["TreatmentCheckBoxes"], "Id", "Status")
.EditorTemplateName("_statusDropDownList")
.ClientTemplate("#=gr_status#")
.Title("ST2")
.Width(120);
columns.Bound(p => p.gr_runno).Title("Run").Width(100);
columns.Bound(p => p.gr_freq).Title("SC").Width(80);
columns.Bound(p => p.gr_prcode).Title("Item").Width(150);
})
.Events(e =>
{
e.DataBound("gridJobAllocation_dataBound");
e.DataBinding("gridJobAllocation_dataBinding");
})
.Editable(e => e.Mode(GridEditMode.InCell))
.Sortable()
.Selectable()
.Scrollable()
.Resizable(r => r.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.HtmlAttributes(new { @style = "cursor: pointer; height: 550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Sort
(
s =>
{
s.Add("gr_sch_date").Descending();
s.Add("gr_sch_time").Ascending();
}
)
.Model(model =>
{
model.Id(o => o.gr_jobno);
model.Field(o => o.gr_status).DefaultValue("DB");
})
.Read(read => read.Action("GetJobs", "Grid").Data("passFilter"))
.Create(create => create.Action("JobAllocation_Create", "JOBS"))
.Update(create => create.Action("JobAllocation_Update", "JOBS"))
.Destroy(create => create.Action("JobAllocation_Destroy", "JOBS"))
)
)
Dropdownlist template
@using ServicePROWeb.Models;
@{
DropDownListItem ddp;
List<
DropDownListItem
> list = new List<
DropDownListItem
>();
foreach(var scheduleCheckBox in (List<
ScheduleCheckBox
>)Session["TreatmentCheckBoxes"])
{
ddp = new DropDownListItem();
ddp.Text = scheduleCheckBox.Status;
ddp.Value = scheduleCheckBox.Status;
list.Add(ddp);
}
}
@(Html.Kendo().DropDownList()
.Name("statusDropDownList")
.DataTextField("Text")
.DataValueField("Value")
.SelectedIndex(4)
.BindTo(list)
.Events(e => e.Select("statusDropDownList_onSelect").DataBound("statusDropDownList_onDataBound").Open("statusDropDownList_onOpen"))
)