javascript - Kendo UI 下拉列表已选中
问题描述
我有一个剑道 ui 功能下拉列表,它将在网格列编辑器中调用。我的问题,默认情况下如何在编辑功能中添加新记录时显示“是” 。目前添加新记录时显示为空。
在这里,我提供了一个工作演示。谢谢你
解决方案
如果我理解正确,您只需在模型中的价格添加默认值?
"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';
}
}
});
});
推荐阅读
- swift - 在应用程序之间切换时未调用 CellForRowAt(内有 gif)
- c# - 如何限制 .Net Core 项目调用的方法?
- java - 在 JAVA 的 Kofax Total Agility 中设置变量值
- javascript - JS - 如何用链式承诺结束数据库连接
- java - 按下后退按钮移动到上一个片段时显示空白屏幕
- nativescript - Nativescript-Vue 超时后关闭模式
- javascript - 克隆表的行
- python - 尝试拟合模型 XgBoost 时元组索引超出范围
- amazon-web-services - 从 Lambda 中检索 SQS 消息内容
- python - 检查数据框中的 ID 是否存在于另一个数据框中的最快方法