Skip to content

Commit

Permalink
Implement Ctrl-A for grid (Fixes #1149) (#1165)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwexler authored Jun 6, 2019
1 parent 3dbf4a2 commit 0b670a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmp/grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ export class Grid extends Component {
}

render() {
const {model, props, agOptions} = this,
{treeMode, agGridModel} = model,
{onKeyDown} = props;
const {model, agOptions, onKeyDown} = this,
{treeMode, agGridModel} = model;

// Note that we intentionally do *not* render the agGridReact element below with either the data
// or the columns. These two bits are the most volatile in our GridModel, and this causes
Expand Down Expand Up @@ -597,6 +596,15 @@ export class Grid extends Component {
return column.isTreeColumn ? node.data[column.field] : value;
}

onKeyDown = (evt) => {
const {selModel} = this.model;
if ((evt.ctrlKey || evt.metaKey) && evt.key == 'a' && selModel.mode === 'multiple') {
selModel.selectAll();
return;
}

if (this.props.onKeyDown) this.props.onKeyDown(evt);
}
}

export const grid = elemFactory(Grid);
9 changes: 9 additions & 0 deletions data/StoreSelectionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ export class StoreSelectionModel {
this.ids = clearSelection ? ids : union(this.ids, ids);
}

/** Select all filtered records. */
@action
selectAll() {
if (this.mode === 'multiple') {
this.select(this.store.records);
}
}


/** Clear the selection. */
@action
clear() {
Expand Down

0 comments on commit 0b670a1

Please sign in to comment.