将DropDownList添加到A网格(Kendo)的弹出菜单

时间:2017-06-29 12:55:16

标签: jquery kendo-ui grid

我有一个Kendo Grid,我需要添加一个DropDownList到我的网格代码是:

$("#grid").kendoGrid({

      dataSource: dataSource,
      pageable: true,
      height: 550,
      toolbar: ["create"],
      columns: [
       { field:"ProductName", title: "Product Name" },

       { command: ["edit"], title: " ", width: "250px" }],
                        editable: "popup"
                    });
                });

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

columns: [
    {
        field: "ENCODE",
        title: "Encoding",
        width: "100px",
        editor: encodingEditor
    }
]

function encodingEditor(container, options) {
    $('<input data-bind="value:' + options.field + '"/>')
      .appendTo(container)
      .kendoDropDownList({
          valuePrimitive: true,
          autoBind: false,
          dataTextField: "NAME",
          dataValueField: "NAME",
          dataSource: encodingDataSource
      });
};

var encodingDataSource = new kendo.data.DataSource({
    data: {
        "items": [
          {
              "NAME": "DOS",
          },
          {
              "NAME": "UKG",
          },
          {
              "NAME": "WIN"
          }
        ]
    },
    schema: {
        data: "items",
        model: {
            fields: {
                NAME: { type: "string" }
            }
        }
    }
});