如何使用 ComboBox 作为 Kendo UI 网格列? [英] How to use ComboBox as Kendo UI grid column?
问题描述
我正在使用剑道网格,我正在尝试将 Name 字段设为具有自己数据源的组合框.我没有收到 javascript 错误,但是当我去编辑网格中的名称字段时,它没有显示 ComboBox.它仍然显示一个输入字段.
I'm working with a kendo grid and I'm trying to make Name field a combobox that has it's own datasource. I'm not getting a javascript error, but when I go to edit the name field in the grid, it is not showing a ComboBox. It still shows an input field.
$(function () {
console.log("ready");
var datasource = new kendo.data.DataSource({
transport: {
read: {
url: "", // Returns all items
dataType: "json"
}
},
pageSize: 10,
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number", editable: false, nullable: false, visible: false },
Name: { type: "string", editable: true, nullable: false, validation: { required: true} },
Description: { type: "string", editable: true, validation: { required: true} }
}
}
}
});
var grid = $("#grid").kendoGrid({
dataSource: datasource,
editable: true,
height: 400,
columns: [
{ field: "Id", width: 200 },
{
field: "Name",
editor: function (container, options) { // This is where you can set other control types for the field.
$('< input name="' + options.field + '"/>').appendTo(container).kendoComboBox({
dataSouce: [{ Id: "1", Name: "MaryMaryMary" }, { Id: "2", Name: "John"}],
dataValueField: "Id",
dataTextField: "Name",
});
}
}
],
dataBound: function (e) {
console.log("DataBound");
}
});
});
我没有收到任何 JavaScript 错误.
I'm not getting any javascript errors.
推荐答案
对于那些现在迫切地"需要自定义编辑器并且迫不及待地等待下一个版本的人,就像我一样...... :-)
For those who "desperately" need a custom editor now and can't wait for next release, just like me... :-)
...这是我的解决方法...将 kendo.all.js 的第 #12320 行更改为:
...here is my workaround... change line #12320 of kendo.all.js to this:
fields: { field: column.field, format: column.format, editor: column.editor },
...瞧!现在该列的编辑器"设置生效了!
...and voilà! Now the "editor" setting for the column makes effect!
我在http://www.kendoui.com/forums/ui/grid/how-to-define-memo-style-editor-for-grid-cells.aspx#1938316
2012 年 1 月 6 日,当前版本为 v2011.3.1129
It was January 6 2012, and the current release was v2011.3.1129
这篇关于如何使用 ComboBox 作为 Kendo UI 网格列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!