【问题标题】:SlickGrid onCellchangeSlickGrid onCellchange
【发布时间】:2013-02-14 18:00:55
【问题描述】:

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

}

【问题讨论】:

    标签: javascript slickgrid


    【解决方案1】:

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

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

    【讨论】:

    • 我看了十几遍,还是错过了。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2014-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多