0

在我的项目中,onSelectedRowsChanged 事件可以在行更改时触发,但也可以在同一行中的活动单元格更改时触发,实际上我们不希望它发生。它在 slickgrid exaple4-model.html 页面中进行了测试,代码在这里:

  grid.onSelectedRowsChanged.subscribe(function (e, args) {
      window.console.log("fire selected events...");
  });

谁能找到一个很好的解决方案来避免这种情况?感谢您的回复或建议。

4

2 回答 2

3
//This works for me:

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

//onCellChange event, track current row.

var rowIndex;

grid.onCellChange.subscribe(function (e, args) {
    rowIndex = args.row;
});

//onSelectedRowsChanged event, if row number was changed call some function.

grid.onSelectedRowsChanged.subscribe(function (e, args) {
    if (grid.getSelectedRows([0])[0] !== rowIndex) {
        call function;
    }
});
于 2013-12-27T12:23:28.587 回答
0

这对我有用

//Declare Global Variable
var lastSelectedId;

grid.onCellChange.subscribe(function (e, args) {
    var selectedItem = grid.getDataItem(grid.getSelectedRows(0[0]);
    if (selectedItem.id != lastSelectedId){ 
        //Actions go here!
    }
    lastSelectedId = selectedItem.id
});
于 2014-11-03T19:40:44.853 回答