我在页面中有一个网格,我想添加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();
}
答案 0 :(得分:2)
Javascript是一种区分大小写的语言。活动名称为onCellChange
(大写C
):
oppLineGrid.onCellChange.subscribe(function(e, args) {
alert('changed');
});