我在页面中有一个网格,我想将 onCellchange 功能添加到其中,但是当我添加它时,它给了我一个 JS 错误说:
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();
}