Permalink
Browse files

Fix #498 - Selections are not always maintained when filtering (Examp…

…le 4).
  • Loading branch information...
1 parent b51762e commit 5b13782a50315f60aa911c360ec28d8ac9f63a42 @mleibman committed Dec 19, 2012
Showing with 25 additions and 17 deletions.
  1. +1 −1 plugins/slick.cellselectionmodel.js
  2. +1 −1 plugins/slick.rowselectionmodel.js
  3. +23 −15 slick.dataview.js
@@ -74,7 +74,7 @@
}
function handleActiveCellChange(e, args) {
- if (_options.selectActiveCell) {
+ if (_options.selectActiveCell && args.row != null && args.cell != null) {
setSelectedRanges([new Slick.Range(args.row, args.cell)]);
}
}
@@ -90,7 +90,7 @@
}
function handleActiveCellChange(e, data) {
- if (_options.selectActiveRow) {
+ if (_options.selectActiveRow && data.row != null) {
setSelectedRanges([new Slick.Range(data.row, 0, data.row, _grid.getColumns().length - 1)]);
}
}
View
@@ -701,12 +701,7 @@
var selectedRowIds = self.mapRowsToIds(grid.getSelectedRows());;
var inHandler;
- grid.onSelectedRowsChanged.subscribe(function(e, args) {
- if (inHandler) { return; }
- selectedRowIds = self.mapRowsToIds(grid.getSelectedRows());
- });
-
- this.onRowsChanged.subscribe(function(e, args) {
+ function update() {
if (selectedRowIds.length > 0) {
inHandler = true;
var selectedRows = self.mapIdsToRows(selectedRowIds);
@@ -716,7 +711,16 @@
grid.setSelectedRows(selectedRows);
inHandler = false;
}
+ }
+
+ grid.onSelectedRowsChanged.subscribe(function(e, args) {
+ if (inHandler) { return; }
+ selectedRowIds = self.mapRowsToIds(grid.getSelectedRows());
});
+
+ this.onRowsChanged.subscribe(update);
+
+ this.onRowCountChanged.subscribe(update);
}
function syncGridCellCssStyles(grid, key) {
@@ -735,15 +739,7 @@
}
}
- grid.onCellCssStylesChanged.subscribe(function(e, args) {
- if (inHandler) { return; }
- if (key != args.key) { return; }
- if (args.hash) {
- storeCellCssStyles(args.hash);
- }
- });
-
- this.onRowsChanged.subscribe(function(e, args) {
+ function update() {
if (hashById) {
inHandler = true;
ensureRowsByIdCache();
@@ -757,7 +753,19 @@
grid.setCellCssStyles(key, newHash);
inHandler = false;
}
+ }
+
+ grid.onCellCssStylesChanged.subscribe(function(e, args) {
+ if (inHandler) { return; }
+ if (key != args.key) { return; }
+ if (args.hash) {
+ storeCellCssStyles(args.hash);
+ }
});
+
+ this.onRowsChanged.subscribe(update);
+
+ this.onRowCountChanged.subscribe(update);
}
return {

0 comments on commit 5b13782

Please sign in to comment.