如何使用ComboBox作为Kendo UI网格列? [英] How to use ComboBox as Kendo UI grid column?

查看:162
本文介绍了如何使用ComboBox作为Kendo UI网格列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用kendo网格,我正在尝试将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

It是2012年1月6日,当前版本是v2011.3.1129

It was January 6 2012, and the current release was v2011.3.1129

这篇关于如何使用ComboBox作为Kendo UI网格列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆