2016-04-08 48 views

回答

2

在你列定義添加一個屬性是這樣的:

headerTemplate: '<input id="dropdown" />' 

然後網格初始化後做: $( 「#下拉列表」)kendoDropDownList({。 ... init參數...});

UPDATE:去dojo.telerik.com並粘貼在下面的代碼:

<div id="grid"></div> 
<script> 
$("#grid").kendoGrid({ 
    columns: [ 
    { 
     field: "ProductName", 
     title: "Product Name", 
     headerTemplate: '<input id="dropdown" />' 
    }, 
    { field: "UnitPrice", title: "Price", template: 'Price: #: kendo.format("{0:c}", UnitPrice)#' } 
    ], 
    pageable: true, 
    dataSource: { 
    transport: { 
     read: { 
     url: "http://demos.telerik.com/kendo-ui/service/products", 
     dataType: "jsonp" 
     } 
    }, 
    pageSize: 10 
    }, 
    excelExport: function(e) { 
    var sheet = e.workbook.sheets[0]; 
    var template = kendo.template(this.columns[1].template); 

    for (var i = 1; i < sheet.rows.length; i++) { 
     var row = sheet.rows[i]; 

     var dataItem = { 
     UnitPrice: row.cells[1].value 
     }; 

     row.cells[1].value = template(dataItem); 
    } 
    } 
}); 

    $("#dropdown").kendoDropDownList({ 
    optionLabel: 'Choose a value...', 
    dataTextField: 'description', 
    dataValueField: 'id', 
    dataSource:{ 
     data: [{id: 1, description: 'One'},{id: 2, description: 'Two'}] 
    }, 
    change: function(e){ 
     //do whatever you need here, for example: 
     var theGrid = $("#grid").getKendoGrid(); 
     var theData = theGrid.dataSource.data(); 
     $(theData).each(function(index,item){ 
     item.ProductName = e.sender.text(); 
     }); 
     theGrid.dataSource.data(theData); 
    } 
    }); 

+1

請你能提供一個工作的例子。 – bagya

+1

也許這[鏈接](http://dojo.telerik.com/@rkonstantinov/afOxa)可以幫助你。第一個標題中有下拉菜單。 (它具有過濾功能,但如果不需要,可以將其刪除) – Ademar

+0

感謝Ademar。自從我把它放在一起以後,我也加入了自己的例子。它在JSFiddle中不起作用,不知道爲什麼,所以我不會發佈一個鏈接,但轉到dojo.telerik.com並粘貼下面的代碼。它添加一個下拉列表並更改列中的所有值(替換爲您需要的任何功能): – Leon

相關問題