2016-11-21 108 views
0

我有最初呈現爲編輯模板動態

$("#dataGrid").kendoGrid({ 
        height: 450, 
        sortable: true, 
        columns:[  
          {field: "Status", title: " ", width:35}, 
          {field: "Year", title:" ", width:50}, 
          {field: "Name", title:" ", width:50} 
          ], 
        dataSource: surveydataSource 
       }); 

我的要求是,在某些函數調用,我想改變「名稱」列的模板劍道網格劍道網格作爲:

$("#dataGrid").kendoGrid({ 
        height: 450, 
        sortable: true, 
        columns:[  
          {field: "Status", title: " ", width:35}, 
          {field: "Year", title:" ", width:50}, 
          {field: "Name", title:" ", width:50, template: "<strong>#: name # </strong>"} 
          ], 
        dataSource: surveydataSource 
       }); 

有沒有更簡單的方法來這樣做,而不是再次建立整個網格?我可以在劍道網格中更改/重置列的模板嗎?

回答

0

嘗試使用Kendo Grid .setOptions()方法進行設置。

var grid = $("#dataGrid").data("kendoGrid"); 
    grid.setOptions({ 
     columns: [  
      {field: "Status", title: " ", width:35}, 
      {field: "Year", title:" ", width:50}, 
      {field: "Name", title:" ", width:50, template: "<strong>#: name # </strong>"} 
     ] 
    }); 
+0

其實這只是一個示例,實際上我的列數量很多,其中很多都有模板。那麼是否還有其他出路只是選擇特定的列並對其應用更改? – user2091061

+1

沒有,因爲'.setOptions()'將覆蓋每個屬性(在這種情況下,** **列)和應用的整體結構和內部重新創建網格。 –