【发布时间】:2015-07-21 09:11:37
【问题描述】:
我在 Kendo Grid 中添加了组合框,如下例所示: http://demos.telerik.com/kendo-ui/grid/editing-custom
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
CityId: {
editable: true,
type: "number",
validation: { required: true }
}, ...
columns: [{
field: "CityId",
title: "City",
editor: cityDropDownEditor,
template: "#=City.Name#",
width: 200,
} ...
function cityDropDownEditor(container, options) {
$('<input required data-text-field="CityName" data-value-field="CityId" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoComboBox({
autoBind: true,
dataTextField: "CityName",
dataValueField: "CityId",
filter: "contains",
index: 1,
autocomplete: true,
dataSource: {
transport: {
read:
{
url: "/Contact/GetCities",
type: "POST",
dataType: "json"
}
}
}});
}
如果我点击添加按钮,组合框显示预填充值 0。如果我在架构中删除行 type: "number" - 组合框显示带有 CityName 的预填充值,其索引在组合框初始化中设置
.kendoComboBox({
index: 1...
但是当我点击提交时,这个值没有到达后端,我看到了异常。如何为组合框添加正确的默认值?
【问题讨论】:
标签: c# kendo-ui kendo-grid