SlickGrid excel类型功能 - 简单

时间:2011-12-28 20:45:35

标签: jquery slickgrid

使用SlickGrid编辑示例来划分duration1 / duration2。这可以在更改的每一行的密钥更改时完成吗?

$(function()
    {


        for (var i=0; i<500; i++) {
            var d = (data[i] = {});

            d["title"] = "Task " + i;
            d["duration1"] = "";
            d["duration2"] = "";
            d["percentComplete"] = (d["duration1"] / d["duration2"]);
            d["start"] = "01/01/2009";
            d["finish"] = "01/05/2009";
            d["effortDriven"] = (i % 5 == 0);
        }

        grid = new Slick.Grid("#myGrid", data, columns, options);

        //grid.registerPlugin(new Slick.CellRangeSelector());

        grid.setSelectionModel(new Slick.CellSelectionModel());

        grid.onAddNewRow.subscribe(function(e, args) {
            var item = args.item;
            var column = args.column;
            grid.invalidateRow(data.length);
            data.push(item);
            grid.updateRowCount();
            grid.render();
        });
    })

1 个答案:

答案 0 :(得分:1)

grid.onCellChange.subscribe(function(e, args) {
  args.item["percentComplete"] = args.item["duration1"] / args.item["duration2"];
  this.updateRow(args.row);
});