2012-12-27 29 views
2

這裏的領域:kendoGrid:從JSON數據下拉框場

{ 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 } 
    }, 

沒有錯誤,只是空組合框沿輸入框出現類別輸入時出錯。

未捕獲的類型錯誤:對象[對象的對象]的屬性「_parse」不是一個函數

我使用的示例here

+0

你可以在JSFiddle或JSBin中爲我們複製這個問題嗎?這會讓我們更容易排除故障。謝謝! –

+0

對不起,不明白如何使用那些:/ – juk

+0

沒問題!只需轉到jsfiddle.net或jsbin.com,您就可以複製您的問題。然後,我們可以分離該代碼並修復它。 –

回答

2

版本是固定的,如伯克荷蘭指出張貼下面答案:

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 
      }, 
      } 
     } 
     }) 
    }