kendoGrid:来自json数据的combobox字段

时间:2012-12-27 16:30:25

标签: ajax combobox kendo-ui

这是字段:

{ field: "category", title: "Category", width: 100, editor: categoryDropDownEditor },

自定义编辑器:

function categoryDropDownEditor(container, options) {
  console.log('used editor')
  $('<input data-text-field="category" data-value-field="category" data-bind="value:'+options.field+'"/>')
    .appendTo(container)
    .kendoDropDownList({
      autoBind: false,
      dataSource: {
        type: "json",
        transport: {
          read: "/api/notes/dumpcats"
        }
      }
    })
}

也在model.fields中:

  category: {
    type: "combobox",
    editable: true,
    validation: { required: true }
  },

没有错误,只需清空组合框和输入框,输入类别时会出现错误。

未捕获的TypeError:对象[object Object]的属性'_parse'不是函数

我使用了示例here

1 个答案:

答案 0 :(得分:2)

问题已得到解决,正如Burke Holland指出的帖子答案如下:

  function categoryDropDownEditor(contrainer, options) {
    $('<input data-text-field="category" data-value-field="category" data-bind="value:' + options.field + '"/>"')
      .appendTo(contrainer)
      .kendoComboBox({
        index: 0,
        placeholder: "Select category",
        dataTextField: "category",
        dataValueField: "category",
        dataSource: {
          transport: {
            read: {
              url: '/api/notes/cats',
              dataType: 'json',
              type: 'GET',
            },
          },
          schema: {
            data: function(reply) {
              return reply.rows
            },
          }
        }
      })
  }
相关问题