Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 93x 93x 46x 46x 6x 6x 6x 6x 3x 1x 1x 1x 2x 2x 1x 2x 3x 1x 1x 2x 2x 1x 1x 1x | import { DataNavigator, IDataNavigator, VerticalDirection } from '../zd-grid';
import { ITreeGrid } from './interfaces';
export class TreeDataNavigator implements IDataNavigator {
private treeGrid: ITreeGrid;
private dataNavigator: IDataNavigator;
constructor(treeGrid: ITreeGrid) {
this.treeGrid = treeGrid;
this.dataNavigator = new DataNavigator(treeGrid);
}
navigateDatasource(direction: VerticalDirection): void {
const { uniqueKey, currentRow } = this.treeGrid.datasource;
const data = this.treeGrid.getData();
const rowIndex = this.treeGrid.findDataIndex(data, currentRow[uniqueKey]);
if (direction === 'up') {
if (rowIndex === -1) {
const lastOpenedRowIdx = this.treeGrid.treeDataStructure.previousOpenedRow(data.length);
this.treeGrid.setCurrentRow(data[lastOpenedRowIdx]);
return;
}
const previousRowIdx = this.treeGrid.treeDataStructure.previousOpenedRow(rowIndex);
if (previousRowIdx > -1) {
this.treeGrid.setCurrentRow(data[previousRowIdx]);
}
return;
}
if (rowIndex === -1) {
this.treeGrid.setCurrentRow(data[0]);
return;
}
const nextRowIdx = this.treeGrid.treeDataStructure.nextOpenedRow(rowIndex);
if (nextRowIdx > -1) {
this.treeGrid.setCurrentRow(data[nextRowIdx]);
}
}
navigatePageUp(): void {
this.dataNavigator.navigatePageUp();
}
navigatePageDown(): void {
this.dataNavigator.navigatePageDown();
}
}
|