Reputation: 1797
In my project, the onSelectedRowsChanged event can be fired when rows changed, but it also can be fired when acitve cell changed in the same row, actually we dont want it happened. It is tested in the slickgrid exaple4-model.html page, and the code is here:
grid.onSelectedRowsChanged.subscribe(function (e, args) {
window.console.log("fire selected events...");
});
Could anyone find a nice solution to avoid this? thanks your reply or advices.
Upvotes: 0
Views: 3541
Reputation: 455
This work for me
//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
});
Upvotes: 0
Reputation: 31
//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;
}
});
Upvotes: 3