I have a Kendo grid that has a requirement for using a conditional dropdown in combination with batch editing.
For instance I need to allow an order enterer set the color of a product from a dropdown, but each product has a potentially different set of available colors.
I have done something similar with InLine editing without a problem and the ajax call to populate the dropdown is getting called correctly in batch mode. The problem appears to be that the #=productId# is not getting correctly parsed by Kendo.
View:
@( Html.Kendo().Grid<Web.Models.StudentGradeView>()
.Name("Students")
.Columns(columns =>
{
columns.Bound(c => c.Id);
columns.Bound(c => c.Price);
columns.Bound(c => c.Color); })
.ToolBar(toolbar =>
{
toolbar.Template( @"
<span class=""pull-left"">
<a class=""btn k-grid-save-changes"" href=""javascript:void(0)""><span class=""k-icon k-update""></span> Save</a>
<a class=""btn k-grid-cancel-changes"" href=""javascript:void(0)""><span class=""k-icon k-cancel""></span> Cancel</a>
</span>"
})
.Events(e => e.Edit("onEdit")) .Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Events(events =>
{
events.Error("error_handler");
})
.Model(model =>
{
model.Id(m => m.Id);
})
.Read(read => read.Action("Product_Read", "Home", new { id = orderId }))
.Update(update => update.Action("Product_Update", "Home"))
)
)
EditorTemplate
@model string
@(
Html.Kendo().DropDownListFor(m => m)
.OptionLabel("Select Color")
.DataTextField("Color")
.DataValueField("Color")
.DataSource(dataSource =>
{
dataSource.Read("ColorsDropDown_Read", "DropDowns", new { Area = "", id = "#=ProductId#" });
})
)
Controller
public ActionResult ColorsDropDown_Read([DataSourceRequest] DataSourceRequest request, string id)
{
List<Grade> rVal = new List<Color>();
rVal = _SystemSettings.AllColors.Where(w => w.ProductId == id)..ToList();
return Json(rVal, JsonRequestBehavior.AllowGet);
}
Thanks!