2

我在页面中有一个网格,我想将 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();

}
4

1 回答 1

2

Javascript 是一种区分大小写的语言。事件名称为onCellChange(大写C):

oppLineGrid.onCellChange.subscribe(function(e, args) {
    alert('changed');
});
于 2013-02-14T18:09:10.987 回答