I am new to the Kendo UI MVC grid. We have a scenario where we have a Kendo UI MVC Grid.
Points to be noted in the grid.
- The columns Finish Date, Machine Id, Master Roll are editable.
- The column Pln Ind is editable based on the other column value.
- We need to update the grid data in batch.
- By default the grid will be empty.
- When we click the Filter button, based on the filter condition the grid data will be loaded.
- The toolbar should be invisible during the load of the page and it should be visible only if the grid is binded with the data.
- The Datepicker need to be displayed in the Finish Date Column. The Combo box need to be displayed in the MachineId column. The Key is content of the combo is dynamic for each row.
My .cshtml file contains
@(Html.Kendo().Grid(Model.PlanOrderToMachineModelList)
.Name("GrdPlanOrderToMachine")
.AutoBind(false)
.BindTo(Model.PlanOrderToMachineModelList)
.Columns(columns =>
{
columns.Bound(p => p.CustomerOrder).Filterable(true).Width(120).Title("Customer Order");
columns.Bound(p => p.SlitPattern).Filterable(false).Width(100).Title("Slit Pattern");
columns.Bound(p => p.FinishSeq).Filterable(false).Width(50).Title("Fin Seq");
columns.Bound(p => p.Status).Filterable(false).Width(50).Title("Status");
columns.Bound(p => p.WorkCenter).Filterable(false).Width(100).Title("Work Center");
columns.Bound(p => p.CSR).Filterable(false).Width(50).Title(("CSR"));
columns.Bound(p => p.Roll).Filterable(false).Width(100).Title("Roll");
columns.Bound(p => p.Width).Filterable(false).Width(100).Title("Width");
columns.Bound(p => p.Length).Filterable(false).Width(100).Title("Length");
columns.Bound(p => p.FinishDate).Filterable(false).Width(100).Title("Finish Date") .ClientTemplate((
@Html.Kendo().DatePicker()
.Name("FDPicker_#=CustomerOrder#")
.Value("#=FinishDate#")
.Format("{0:dd/MM/yyyy}")
.ToClientTemplate()).ToHtmlString());
columns.Bound(p => p.ShipDate).Filterable(false).Width(100).Title("Ship Date").Format("{0:dd/MM/yyyy}");
columns.Bound(p => p.FinishTime).Filterable(false).Width(100).Title("Finish Time").Format("{0:HH:mm}");
columns.Bound(p => p.ShipTime).Filterable(false).Width(100).Title("Ship Time").Format("{0:HH:mm}");
columns.Bound(p => p.PackageId).Filterable(false).Width(100).Title("Pkg");
columns.Bound(p => p.OrderType).Filterable(false).Width(100).Title("Ord Type");
columns.Bound(p => p.ServiceVariant).Filterable(false).Width(100).Title("Srvc. Vmt");
columns.Bound(p => p.TentativeInd).Filterable(false).Width(100).Title("Ttty");
columns.Bound(p => p.Machines).Filterable(false).Width(100).Title("Mach ID").ClientTemplate((
@Html.Kendo().ComboBox()
.Name("Machines_#=CustomerOrder#")
.DataTextField("MachineId")
.DataValueField("MachineId")
.HtmlAttributes(new { style = "width:250px" })
//.Filter("contains")
//.AutoBind(false)
//.MinLength(3)
//.BindTo((System.Collections.IEnumerable)"#=Machines#")
//.BindTo((System.Collections.IEnumerable)Model.Machines[0].MachineId)
.ToClientTemplate()).ToHtmlString());
//.DataSource(p => p.Machines)
//columns.Bound(p => p.Machines).Filterable(false).Width(100).Title("Mach ID").ClientTemplate("#=Machines.MachineId#");
columns.Bound(p => p.PlanningInd).Filterable(false).Width(100).Title("Pln Ind");
columns.Bound(p => p.PlanningSeq).Filterable(false).Width(100).Title("Seq");
columns.Bound(p => p.Grd).Filterable(false).Width(100).Title("Grd");
columns.Bound(p => p.Message).Filterable(false).Width(100).Title("Msg");
columns.Bound(p => p.MasterRoll).Filterable(false).Width(100).Title("Master-roll");
columns.Bound(p => p.MasterRollDesc).Filterable(false).Width(100).Title("Master-roll Description");
columns.Bound(p => p.Customer).Filterable(false).Width(100).Title("Customer");
columns.Bound(p => p.SumOfSlitWidth).Filterable(false).Width(100).Title("SumOfSlitWidth").Hidden(true);
columns.Bound(p => p.MaximumCrossWidth).Filterable(false).Width(100).Title("MaximumCrossWidth").Hidden(true);
columns.Bound(p => p.ProductWidth).Filterable(false).Width(100).Title("ProductWidth").Hidden(true);
})
//.ToolBar(toolbar =>
//{
// toolbar.Save();
//})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Resizable(resize=>resize.Columns(true))
.Editable(p => p.Mode(GridEditMode.InCell))
.HtmlAttributes(new { style = "height:400px;width:900px" })
.Events(e => e.DataBound("onGridDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Batch(true)
.Model(model =>
{
model.Id(p => p.CustomerOrder);
model.Field(p => p.CustomerOrder).Editable(false);
model.Field(p => p.SlitPattern).Editable(false);
model.Field(p => p.FinishSeq).Editable(false);
model.Field(p => p.Status).Editable(false);
model.Field(p => p.WorkCenter).Editable(false);
model.Field(p => p.CSR).Editable(false);
model.Field(p => p.Roll).Editable(false);
model.Field(p => p.Width).Editable(false);
model.Field(p => p.Length).Editable(false);
model.Field(p => p.FinishDate).Editable(false);
model.Field(p => p.ShipDate).Editable(false);
model.Field(p => p.ShipTime).Editable(false);
model.Field(p => p.PackageId).Editable(false);
model.Field(p => p.OrderType).Editable(false);
model.Field(p => p.ServiceVariant).Editable(false);
model.Field(p => p.TentativeInd).Editable(false);
model.Field(p => p.PlanningSeq).Editable(false);
model.Field(p => p.Grd).Editable(false);
model.Field(p => p.Message).Editable(false);
model.Field(p => p.MasterRoll).Editable(false);
model.Field(p => p.MasterRollDesc).Editable(false);
model.Field(p => p.Customer).Editable(false);
})
.Read(read => read.Action("Index", "PlanOrderToMachine").Data("AdditionalParameters"))
.PageSize(10)
.Update("Index","Home")
)
)
I am getting the combobox and the datepicker, but the values are not binded. It is coming as empty. Please help me to solve this issue. I am using Client Template.
Please give a code sample, that will help me better.
Kind Regards,
Suniel