【发布时间】:2014-01-19 19:25:11
【问题描述】:
我将 Combobox 绑定到一个复杂对象,该绑定使得 ID 字段可用作该对象的直接属性,但文本属性来自子对象属性。
我已经能够配置它正确显示值,但是在指定选项标签时遇到问题说“选择”无法指定 Parent.Childproperty 获取运行时错误(未捕获的 TypeError:无法读取属性'Childproperty' of undefined )
如何在模型定义及下方为空选择指定复杂对象?
$('<input id="DegreeDDL" name="' + options.field + '"/>').appendTo(container).kendoDropDownList({
autoBind: true,
serverFiltering: true,
optionLabel: {
'Parent.Childproperty': "--- Select ---",
ABCD_PK: null
},
dataSource: {
transport: {
read: {
url: function (e) {
return "api/Org/XXXXXXXX?abcdPK=" + efgh;
},
dataType: "json" // <-- The default was "jsonp"
}
},
},
dataTextField: "Parent.ChildProperty",
dataValueField: "ABCD_PK"
});
在为网格定义模型时也遇到了类似的问题
var model = {
id: "ABCD_PK",
fields: {
Parent.Child.ChilProperty:
}
}
【问题讨论】:
-
我不想抱怨,但这是 DropDownList 而不是你在标题中提到的 ComboBOx,在你的代码中你有
dataTextField: "Parent.ChildProperty"然后Parent.Child.ChilProperty:与Child在父级之后的属性并且没有任何东西结肠后。请修复您的代码。
标签: kendo-ui kendo-grid kendo-combobox