2013-02-14 48 views
2

我在頁面上一個網格,我想補充的onCellchange functionalitiy,但是當我添加它,它給了我一個JS錯誤說:SlickGrid onCellchange

oppLineGrid.onCellchange.subscribe(function (e, args) {  
     Uncaught TypeError: Cannot call method 'subscribe' of undefined 
      alert('changed'); 
     }); 

這裏是我的代碼排序功能正在工作,我在想,onCellchange只是沒有按正確的順序添加。非常感謝。

function loadOppLineGrid(data) { 
    oppLineGrid = new Slick.Grid("#oppLineGrid", data, oppLineColumns, oppLineOptions); 

    oppLineGrid.onCellchange.subscribe(function (e, args) { 
     alert('changed'); 
    }); 

    oppLineGrid.onSort.subscribe(function (e, args) { 
     var cols = args.sortCols; 

     oppLineGridData.sort(function (dataRow1, dataRow2) { 
      for (var i = 0, l = cols.length; i < l; i++) { 
       var field = cols[i].sortCol.field; 
       var sign = cols[i].sortAsc ? 1 : -1; 
       var value1 = dataRow1[field], value2 = dataRow2[field]; 
       var result = (value1 == value2 ? 0 : (value1 > value2 ? 1 : -1)) * sign; 
       if (result != 0) { 
        return result; 
       } 
      } 
      return 0; 
     }); 
     oppLineGrid.invalidate(); 
     oppLineGrid.render(); 
    }); 
    oppLineGrid.init(); 

} 

回答

2

Javascript是區分大小寫的語言。事件名稱是onCellChange(資本C):

oppLineGrid.onCellChange.subscribe(function(e, args) { 
    alert('changed'); 
}); 
+0

我看着通過了十幾次,仍然錯過了。謝謝。 – user2073077 2013-02-14 20:13:43