2016-12-02 4 views
0

現在のアイテムを削除するボタンが付いた剣道グリッドがあります。グリッドには行テンプレートがあります。私は剣道のクリックイベントをバインドできませんmvvmの行テンプレート

kendo.binder.min.js?cdv=40:25 Uncaught TypeError: t.get is not a function(…)

場合:

<div class="form-horizontal"> 
     <table class="fixed-table-width" 
      data-role="grid" 
      data-bind="source: data" 
      data-scrollable="false" 
      data-row-template="row-template"> 
      <thead> 
       <tr> 
        <th>Item</th> 
        <th></th> 
       </tr> 
      </thead> 
     </table> 
    </div> 
    <script type="text/x-kendo-tmpl" id="row-template"> 
    <tr> 
     <td><span data-bind="text: item"></span></td> 
     <td><button class="link" data-bind="click: remove"><i class="icon-trash"></i> Remove</button></br ></td> 
    </tr> 
    </script> 

そして、それは私のモデルである:ここに私のHTMLはある

function AddItemComponent($scope) { 
    if ($scope === null || $scope === undefined) throw new Error("Unknown scope, please provide the scope"); 

    var self = this; 

    self.itemModel = { 
     item: "Item to Remove", 
     remove: function(i) { 
      self.viewModel.items = self.viewModel.items.splice(i); 
     } 
    }; 
    self.viewModel = kendo.observable({ 
     items: [] 
    }); 

    self.viewModel.items.push(self.itemModel); 
}; 

しかし、私はこのHTMLをモーダルを開くと、私は次のエラーを取得しますデータバインドをクリックイベントから削除すると、エラーはなく、うまくいきます。何が問題なのですか?あなたが達成しようとしている何

答えて

0

は、より良いあなたはもう行テンプレートをneeedないコマンド列

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.command

data-columns="[{ field: 'item' }, { command: 'destroy' }]" 

で行われます。

取得()はkendo.data.ObservableObject

self.itemModel = kendo.observable({ 
    item: "Item to Remove", 
    remove: function(i) { 
     self.viewModel.items = self.viewModel.items.splice(i); 
    } 
}); 
からの方法であるとして、あなたは、観測可能で、あなたのitemModelをラップしようとすると、これを行うにはしたくない場合
関連する問題