Kendo UI 已选中下拉列表
Kendo UI Dropdownlist checked
我有一个 kendo ui 函数下拉列表,它会调用网格列编辑器。我的问题是,默认情况下如何在编辑功能中 Add New Record 时显示“Yes”。目前添加新记录时显示为空
这里我提供一个工作演示。 谢谢
如果我没理解错的话,您只需在模型中的价格中添加一个默认值即可?
"Price": {type: "string", defaultValue: "y" },
为了以防万一,我包含了整个函数:
$(function() {
$("#grid").kendoGrid({
dataSource: {
data: [
{ Name: "Young John", Price: "y" },
{ Name: "John Doe", Price: "n" },
{ Name: "Old John", Price: "y" }
],
schema: {
model: {
id: "id",
fields: {
"id": { type: "number" },
"Price": {type: "string", defaultValue: "y" },
}
}
}
},
editable: "inline",
toolbar: ["create"],
columns: [{ field: "Name"},
{ field: "Price",
template: "#=(data.Price == 'y' ? 'Yes' : 'No')#",
editor: radioPrice
} ],
edit: function(e) {
if (e.model.isNew()) {
e.model.Price = 'y';
}
}
});
});
我有一个 kendo ui 函数下拉列表,它会调用网格列编辑器。我的问题是,默认情况下如何在编辑功能中 Add New Record 时显示“Yes”。目前添加新记录时显示为空
这里我提供一个工作演示。 谢谢
如果我没理解错的话,您只需在模型中的价格中添加一个默认值即可?
"Price": {type: "string", defaultValue: "y" },
为了以防万一,我包含了整个函数:
$(function() {
$("#grid").kendoGrid({
dataSource: {
data: [
{ Name: "Young John", Price: "y" },
{ Name: "John Doe", Price: "n" },
{ Name: "Old John", Price: "y" }
],
schema: {
model: {
id: "id",
fields: {
"id": { type: "number" },
"Price": {type: "string", defaultValue: "y" },
}
}
}
},
editable: "inline",
toolbar: ["create"],
columns: [{ field: "Name"},
{ field: "Price",
template: "#=(data.Price == 'y' ? 'Yes' : 'No')#",
editor: radioPrice
} ],
edit: function(e) {
if (e.model.isNew()) {
e.model.Price = 'y';
}
}
});
});