我想做的是:
- This Kendo UI Grid control has 8 columns in which 2 columns has a Kendo dropdownlist(EditorTemplate) and CheckBox(EditorTemplate).
- The Kendo UI Grid control is Ajax binding.
问题或我所面临的问题:
表单的前半部分与其他Kendo控件一起正确地将它们的值提交给控制器,但是由于Kendo在发布一些列值时遇到了一些问题
"[Object Object]"
和布尔值而不是复选框控件的实际值。发布于 2013-02-20 03:51:55
我怀疑您是否希望将Grid作为表单的一部分。通常,Grid通过ajax进行交互,而不是通过批处理表单提交与其他控件进行交互--将其从表单中展开。光是这一点就能帮你避免头痛。
上半年:
尝试使用Kendo().DatePickerFor()、Kendo().DropDownListFor()等。您不需要通过.Name()显式地命名这些Kendo控件。这将帮助您进行模型绑定。
下半部分:
使用十进制以外的另一种数据类型。你觉得这很难吗?尝试使用TimeSpan类型作为一天的时间,没有日期附加(成年男子哭泣)。
您通常不需要布尔/复选框的EditorTemplate。只需使用这个技巧(因为您没有留下代码,所以您正在使用Razor )。
columns.Bound(b => b.IsActive).ClientTemplate("<input type='checkbox' ${ IsActive == true ? checked='checked' : ''} disabled />");
网格DDL的最佳选择是
columns.ForeignKey(b => b.CustodianIdPrimary, Model.Custodians, "Id", "FullName").EditorViewData(new {ProjectId = Model.ProjectId}).EditorTemplateName("CustodianDropDownList");
其中Model.Custodians是所有可能项的列表。然后,您可以将您的EditorTemplate绑定到此列表,或者在需要此特定DDL中的子集时进行ajax调用以填充,如下所示
@model int
@(Html.Kendo().DropDownList()
.Name(ViewData.TemplateInfo.GetFullHtmlFieldName(""))
.DataValueField("Id")
.DataTextField("FullName")
.OptionLabel("Unassigned")
.DataSource(dataSource => dataSource
.Read(read => read.Action("ReadProjectCustodiansDdl", "SysMaint", new {projectId = ViewData["ProjectId"]}))
)
)
但是下面是Kendo提供的例子
@model object
@(
Html.Kendo().DropDownListFor(m => m)
.BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)
注意EditorViewData参数在我的初始columns.ForeignKey中的使用,这个参数在这个示例中用于传递整个列表。
祝好运!
https://stackoverflow.com/questions/14964838
复制相似问题