Selection in grid context (#2527)

* update action context on selection change

* correctly add ranges rather than a new range for every row

* add required functions to typings
This commit is contained in:
Anthony Dresser
2018-09-11 17:10:53 -07:00
committed by Karl Burtram
parent c559ac7be9
commit 89e6d363e2
6 changed files with 47 additions and 24 deletions

View File

@@ -52,7 +52,13 @@ export class AdditionalKeyBindings<T> implements Slick.Plugin<T> {
} else if (event.equals(KeyCode.End | KeyMod.CtrlCmd)) {
this.grid.setActiveCell(this.grid.getDataLength() - 1, this.grid.getColumns().length - 1);
} else if (event.equals(KeyCode.KEY_A | KeyMod.CtrlCmd)) {
this.grid.setSelectedRows(range(this.grid.getDataLength()));
// check if we can set the rows directly on the selectionModel, its cleaner
let selectionModel = this.grid.getSelectionModel();
if (selectionModel) {
selectionModel.setSelectedRanges([new Slick.Range(0, 0, this.grid.getDataLength() - 1, this.grid.getColumns().length - 1)]);
} else {
this.grid.setSelectedRows(range(this.grid.getDataLength()));
}
} else {
handled = false;
}

View File

@@ -38,8 +38,8 @@ export class CopyKeybind<T> implements Slick.Plugin<T> {
let selectionModel = this.grid.getSelectionModel();
let ranges: Slick.Range[];
// check to see if we can get the range from the model directly
if (selectionModel && (<any>selectionModel).getSelectedRanges) {
ranges = (<any>selectionModel).getSelectedRanges();
if (selectionModel) {
ranges = selectionModel.getSelectedRanges();
} else {
let selectedRows = this.grid.getSelectedRows();
let startColumn = 0;

View File

@@ -166,6 +166,10 @@ export class Table<T extends Slick.SlickData> extends Widget implements IThemabl
this._grid.setData(this._data, true);
}
getData(): Slick.DataProvider<T> {
return this._data;
}
get columns(): Slick.Column<T>[] {
return this._grid.getColumns();
}