2012-09-04 106 views
1

我在考慮使用Kendo UI的網格。Kendo UI - 帶自定義自動完成功能的網格

但是,我有點不確定它的靈活性和定製。 我真正需要的是在線編輯,但同時我想完全控制這一點。例如,我們開發了一個自定義的自動完成(使用jquery和javascript)。並希望在Kendo UI的Grid中使用此自定義自動完成功能。 我不知道是否有人已經使用這種方法,因爲我無法在Kendo UI中找到這種級別的定製。

謝謝。

Joseph。

回答

4

在內聯編輯中實現kendo網格時,可以爲每個單獨的字段指定自定義編輯器。例如,它可以在使用這種配置來完成:

   columns: [ 
        { field:"ProductName",title:"Product Name" }, 
        { field: "Category", width: "150px", editor: categoryDropDownEditor }, 
        { field: "UnitPrice", title:"Unit Price", format: "{0:c}", width: "150px" }, 
        { command: "destroy", title: " ", width: "110px" }], 
       editable: true 

其中用於categoryDropDownEditor的代碼如下所示:

function categoryDropDownEditor(container, options) { 
        $('<input data-text-field="CategoryName" data-value-field="CategoryName" data-bind="value:' + options.field + '"/>') 
         .appendTo(container) 
         .kendoDropDownList({ 
          autoBind: false, 
          dataSource: { 
           type: "odata", 
           transport: { 
            read: "http://demos.kendoui.com/service/Northwind.svc/Categories" 
           } 
          } 
         }); 
       } 

這裏會發生什麼事是,categoryDropDownEditor功能爲創建acutal標記編輯器,針對該特定領域。在你的情況下,唯一需要做的就是實現一個自動完成小部件,而不是一個下拉列表。這個例子是從劍道UI的demo page

我希望能回答你的問題!

+0

感謝您花時間回覆我的問題並回答這個問題,非常感謝! –

+0

我會在幾分鐘內標記爲答案...因爲它不允許我:)謝謝! –

+0

沒問題,我很樂意幫助:)我實現了很多我的自我,當你掌握它時,你真的可以節省一些時間。 – Logard