2014-07-11 58 views
1

配置我已經看到了幾個綁定kendo網格使用淘汰賽的例子,其中在視圖模型中定義網格配置。我非常喜歡這種風格以及它允許​​的乾淨標記。但是,我似乎無法得到usekotemplates選項。綁定Kendo網格與淘汰賽:將在JavaScript中配置與

這裏是我的標記:

<div data-bind='kendoGrid: gridConfig'></div> 
<script id="clientRowTemplate" type="text/html"> 
    <tr> 
     <td data-bind="text: Name"></td> 
     <td data-bind="text: State"></td> 
     <td> 
      <input type="hidden" data-bind="value: Id" /> 
      <a href="#">Edit</a> 
      <a href="#">Delete</a> 
     </td> 
    </tr> 
</script> 

這裏是我的視圖模型

var clientListViewModel = function() { 

    var self = this; 
    self.clients = ko.observableArray([]); 

    self.load = function() { 
     for (var i = 0; i < 9; i++) { 
      var c = new clientModel(); 
      c.Id = i; 
      c.Name = 'Name' + i; 
      c.State = 'NY'; 
      self.clients.push(c); 
     }; 
    }; 

    self.gridConfig = { 
     data: self.clients, 
     datasource: { 
      data: "data", 
      schema: { 
       model: { 
        fields: { 
         ID: { type: "number" }, 
         Name: { type: "string" }, 
         State: { type: "string" } 
        } 
       } 
      }, 
      pageSize: 10, 
      serverPaging: true 
     }, 
     height: 400, 
     pageable: true, 
     selectable: "row", 
     usekotemplates: true, 
     rowtemplate: "clientRowTemplate", 
    }; 

}; 

var clientModel = function() { 
    var self = this; 
    self.Id = ko.observable(0); 
    self.Name = ko.observable("").extend({ required: true }); 
    self.State = ko.observable("").extend({ required: true }); 
}; 


var vm = new clientListViewModel(); 
vm.load(); 
ko.applyBindings(vm); 

這裏有一個的jsfiddle:http://jsfiddle.net/Steve5877/a4kG7/2/

我可以這樣綁定,並仍然使用模板?

回答

4

看起來像你只需要觀看的一對夫婦的選項要傳遞的大小寫:

useKOTemplates: true, 
    rowTemplate: "clientRowTemplate", 

而不是:

usekotemplates: true, 
    rowtemplate: "clientRowTemplate",