@guiexpert/table 1.1.90 → 1.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/css/main.css +129 -4
- package/css/table-classes.css +93 -0
- package/css/table-color-classes.css +3 -1
- package/css/table-color-vars.css +20 -2
- package/css/table-tree.css +13 -1
- package/index.cjs +111 -96
- package/index.d.ts +203 -184
- package/index.js +4927 -2096
- package/lib/common/debounce.d.ts +1 -0
- package/lib/common/decorator/avoid-double-execution.decorator.d.ts +2 -0
- package/lib/common/escape-html.d.ts +22 -0
- package/lib/common/generator/column-def-generator-service.d.ts +2 -1
- package/lib/common/generator/domain/property-type.d.ts +19 -0
- package/lib/common/generator/domain/value-info.d.ts +2 -1
- package/lib/common/generator/json-service.d.ts +1 -0
- package/lib/common/generator/property-type.service.d.ts +3 -2
- package/lib/common/generator/scheme-generator-service.d.ts +3 -1
- package/lib/common/generator/string-util.d.ts +7 -0
- package/lib/common/throttle.d.ts +1 -0
- package/lib/table/action/action-id.type.d.ts +5 -1
- package/lib/table/action/on-action-triggered.if.d.ts +2 -1
- package/lib/table/action/osx-shortcut-actionId-mapping.d.ts +3 -1
- package/lib/table/action/shortcut-actionid-mapping.type.d.ts +3 -1
- package/lib/table/action/shortcut-util.d.ts +12 -0
- package/lib/table/action/shortcut.service.d.ts +5 -3
- package/lib/table/action/windows-shortcut-actionId-mapping.d.ts +3 -1
- package/lib/table/aria/aria-grid-info.d.ts +76 -0
- package/lib/table/aria/aria-ids.d.ts +56 -0
- package/lib/table/aria/aria-texts.d.ts +34 -0
- package/lib/table/aria/aria-texts.if.d.ts +88 -0
- package/lib/table/aria/live-announcer.d.ts +62 -0
- package/lib/table/aria/tree-aria-info.d.ts +58 -0
- package/lib/table/checkbox/all-rows-checkbox-model.d.ts +31 -0
- package/lib/table/checkbox/checkbox-model.d.ts +3 -2
- package/lib/table/checkbox/checkbox-model.if.d.ts +2 -1
- package/lib/table/checkbox/tree-checkbox-model.d.ts +19 -4
- package/lib/table/color/color-rgb.d.ts +2 -1
- package/lib/table/color/color-rgb.if.d.ts +2 -0
- package/lib/table/color/ge-css-color-util.d.ts +25 -2
- package/lib/table/color/three-color-gradient-arg.d.ts +3 -2
- package/lib/table/color/three-color-gradient-arg.if.d.ts +3 -1
- package/lib/table/color/two-color-gradient-arg.d.ts +3 -2
- package/lib/table/color/two-color-gradient-arg.if.d.ts +3 -1
- package/lib/table/crud/column-widths.d.ts +2 -1
- package/lib/table/crud/column-widths.if.d.ts +1 -0
- package/lib/table/crud/crud-action.d.ts +1 -0
- package/lib/table/crud/crud-object-edit.d.ts +25 -3
- package/lib/table/crud/crud-object-view.d.ts +6 -0
- package/lib/table/crud/crud-options.d.ts +35 -4
- package/lib/table/crud/crud-options.if.d.ts +3 -2
- package/lib/table/crud/crud-table-model-factory.d.ts +72 -8
- package/lib/table/crud/url-info.d.ts +2 -1
- package/lib/table/crud/url-info.if.d.ts +1 -0
- package/lib/table/crud/urls.if.d.ts +2 -1
- package/lib/table/css-vars.d.ts +1 -0
- package/lib/table/data/chunk/chunk.data-event.d.ts +3 -2
- package/lib/table/data/chunk/chunk.data-event.if.d.ts +2 -1
- package/lib/table/data/chunk/request-chunk.d.ts +2 -1
- package/lib/table/data/chunk/request-chunk.if.d.ts +1 -0
- package/lib/table/data/common/aligns.d.ts +18 -0
- package/lib/table/data/common/area-map-factory.d.ts +3 -2
- package/lib/table/data/common/area-map.d.ts +3 -1
- package/lib/table/data/common/area-map.type.d.ts +1 -0
- package/lib/table/data/common/args-adjust-columns-to-row-parent-params.d.ts +6 -4
- package/lib/table/data/common/args-render-cell-div.d.ts +5 -3
- package/lib/table/data/common/boolean-function.d.ts +10 -0
- package/lib/table/data/common/cell-range.d.ts +16 -7
- package/lib/table/data/common/checkbox-column-def.d.ts +6 -4
- package/lib/table/data/common/checked-type.d.ts +2 -0
- package/lib/table/data/common/event/ge-cell-indices.d.ts +2 -0
- package/lib/table/data/common/event/ge-key-event.d.ts +2 -0
- package/lib/table/data/common/event/ge-model-change-event.d.ts +16 -2
- package/lib/table/data/common/event/ge-mouse-event.d.ts +52 -4
- package/lib/table/data/common/event/ge-scroll-event.d.ts +27 -1
- package/lib/table/data/common/event/ge-state-change-event.d.ts +30 -0
- package/lib/table/data/common/event/input/table-cell-update-event.d.ts +14 -10
- package/lib/table/data/common/event/input/table-cell-update-event.if.d.ts +3 -1
- package/lib/table/data/common/filter-function.d.ts +2 -0
- package/lib/table/data/common/get-t.d.ts +2 -0
- package/lib/table/data/common/index-and-px.d.ts +2 -0
- package/lib/table/data/common/size-unit.type.d.ts +2 -0
- package/lib/table/data/common/size.d.ts +13 -2
- package/lib/table/data/common/size.if.d.ts +3 -1
- package/lib/table/data/common/sizes.d.ts +133 -1
- package/lib/table/data/common/sort-item.d.ts +16 -3
- package/lib/table/data/common/sort-state.type.d.ts +2 -0
- package/lib/table/data/common/tree-arrow.type.d.ts +2 -0
- package/lib/table/data/common/tree-row-if.d.ts +22 -1
- package/lib/table/data/common/tree-row.d.ts +3 -1
- package/lib/table/data/common/value-label.d.ts +2 -1
- package/lib/table/data/common/value-label.if.d.ts +1 -0
- package/lib/table/data/div-scope.type.d.ts +2 -0
- package/lib/table/data/event/mouse-target-data.d.ts +5 -3
- package/lib/table/data/geo-data.d.ts +2 -0
- package/lib/table/data/options/auto-restore-options.d.ts +44 -1
- package/lib/table/data/options/auto-restore-options.if.d.ts +95 -45
- package/lib/table/data/options/default-row-heights.d.ts +20 -2
- package/lib/table/data/options/default-row-heights.if.d.ts +4 -1
- package/lib/table/data/options/default-row-id.d.ts +4 -0
- package/lib/table/data/options/header-group-options.d.ts +3 -2
- package/lib/table/data/options/header-group-options.if.d.ts +3 -4
- package/lib/table/data/options/icon.d.ts +2 -1
- package/lib/table/data/options/icon.if.d.ts +2 -0
- package/lib/table/data/options/overlay-options.d.ts +30 -0
- package/lib/table/data/options/overlay-options.if.d.ts +79 -0
- package/lib/table/data/options/sorted-options.d.ts +3 -2
- package/lib/table/data/options/sorted-options.if.d.ts +3 -1
- package/lib/table/data/options/table-options.d.ts +40 -13
- package/lib/table/data/options/table-options.if.d.ts +152 -44
- package/lib/table/data/options/tree-options.d.ts +3 -2
- package/lib/table/data/options/tree-options.if.d.ts +3 -1
- package/lib/table/data/side-ident.type.d.ts +2 -0
- package/lib/table/data/table-model-and-options.d.ts +5 -3
- package/lib/table/data/table-model-and-options.if.d.ts +4 -2
- package/lib/table/data/tablemodel/area-ident.type.d.ts +4 -0
- package/lib/table/data/tablemodel/areamodel/abstract-area-model.d.ts +10 -9
- package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +13 -4
- package/lib/table/data/tablemodel/areamodel/area-model-cell-groups.d.ts +44 -12
- package/lib/table/data/tablemodel/areamodel/area-model-hidden.d.ts +9 -7
- package/lib/table/data/tablemodel/areamodel/area-model-object-array-with-columndefs.d.ts +16 -14
- package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +48 -31
- package/lib/table/data/tablemodel/areamodel/area-model-tree.d.ts +162 -11
- package/lib/table/data/tablemodel/areamodel/area-model.d.ts +66 -104
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +75 -50
- package/lib/table/data/tablemodel/areamodel/async-area-model-object-array.d.ts +5 -5
- package/lib/table/data/tablemodel/areamodel/col-and-rowspan-model.d.ts +14 -3
- package/lib/table/data/tablemodel/areamodel/cover-grid-body-model.d.ts +17 -8
- package/lib/table/data/tablemodel/areamodel/has-default-row-height-if.d.ts +1 -0
- package/lib/table/data/tablemodel/areamodel/object-array-holder.if.d.ts +1 -0
- package/lib/table/data/tablemodel/cellgroup/cell-group-ext.d.ts +3 -2
- package/lib/table/data/tablemodel/cellgroup/cell-group.d.ts +4 -1
- package/lib/table/data/tablemodel/cellgroup/cell-group.if.d.ts +34 -0
- package/lib/table/data/tablemodel/cellgroup/cellgroup-factory.d.ts +4 -3
- package/lib/table/data/tablemodel/column/column-def.d.ts +67 -10
- package/lib/table/data/tablemodel/column/column-def.if.d.ts +63 -96
- package/lib/table/data/tablemodel/column/column-visibility.d.ts +11 -0
- package/lib/table/data/tablemodel/cover-grid-table-model.d.ts +11 -10
- package/lib/table/data/tablemodel/padding.d.ts +2 -0
- package/lib/table/data/tablemodel/table-model.d.ts +75 -14
- package/lib/table/data/tablemodel/table-model.if.d.ts +52 -8
- package/lib/table/ele-scope.d.ts +53 -5
- package/lib/table/event-adapter.d.ts +20 -10
- package/lib/table/event-checkbox-changed-handler.d.ts +2 -1
- package/lib/table/event-listener.if.d.ts +50 -9
- package/lib/table/factory/cover-grid-factory.d.ts +4 -3
- package/lib/table/factory/table-factory.d.ts +103 -64
- package/lib/table/factory/tree-factory.d.ts +45 -3
- package/lib/table/focus/event-focus-changed-listener.if.d.ts +5 -3
- package/lib/table/focus/focus-model.d.ts +7 -5
- package/lib/table/focus/focus-model.if.d.ts +22 -1
- package/lib/table/focus/focus.type.d.ts +2 -0
- package/lib/table/input-handler.d.ts +5 -1
- package/lib/table/instanceof-workaround.d.ts +16 -0
- package/lib/table/license-manager.d.ts +2 -0
- package/lib/table/mouse-handler.d.ts +20 -9
- package/lib/table/overlay/calc-overlay-kind.d.ts +31 -0
- package/lib/table/overlay/ge-overlay-kind.type.d.ts +17 -0
- package/lib/table/overlay/table-overlay.d.ts +108 -0
- package/lib/table/render-scope.d.ts +141 -27
- package/lib/table/renderer/action/action-event-listener.if.d.ts +2 -1
- package/lib/table/renderer/action/action-event.d.ts +4 -3
- package/lib/table/renderer/action/action-event.if.d.ts +2 -1
- package/lib/table/renderer/action/actions-cell-renderer.d.ts +8 -7
- package/lib/table/renderer/cell-group-ext-cell-renderer.d.ts +8 -7
- package/lib/table/renderer/cell-render.if.d.ts +41 -4
- package/lib/table/renderer/checkbox-boolean-property-cell-renderer.d.ts +7 -5
- package/lib/table/renderer/checkbox-cell-renderer.d.ts +8 -5
- package/lib/table/renderer/date-to-int-date-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/date-to-iso-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/date-to-locale-date-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/date-to-tec-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/edit/edit-cell-renderer.type.d.ts +2 -1
- package/lib/table/renderer/edit/edit-input-pipe-for-number.d.ts +2 -1
- package/lib/table/renderer/edit/edit-input-pipe.if.d.ts +2 -0
- package/lib/table/renderer/edit/input-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/edit/select-cell-renderer.d.ts +7 -6
- package/lib/table/renderer/male-female-to-icon-cell-renderer.d.ts +19 -6
- package/lib/table/renderer/number-cell-progress-bar-cell-renderer.d.ts +11 -6
- package/lib/table/renderer/number-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/positive-and-negative-number-renderer.d.ts +6 -5
- package/lib/table/renderer/progress-bar-cell-renderer.d.ts +12 -6
- package/lib/table/renderer/renderer-cleanup-fn.type.d.ts +1 -0
- package/lib/table/renderer/renderer.d.ts +3 -2
- package/lib/table/renderer/simple-array-cell-renderer.d.ts +6 -5
- package/lib/table/renderer/star-rating-cell-renderer.d.ts +12 -6
- package/lib/table/renderer/true-false-cell-renderer.d.ts +17 -5
- package/lib/table/resize-handler.d.ts +3 -1
- package/lib/table/selection/event-selection-changed-listener.if.d.ts +2 -1
- package/lib/table/selection/multi-rows-selection-model.d.ts +7 -4
- package/lib/table/selection/selection-model.d.ts +112 -10
- package/lib/table/selection/selection-model.if.d.ts +48 -3
- package/lib/table/selection/selection-service.d.ts +35 -7
- package/lib/table/selection/selection.type.d.ts +3 -0
- package/lib/table/service/abstract-store-state.service.d.ts +1 -1
- package/lib/table/service/convenience-dom.service.d.ts +37 -14
- package/lib/table/service/copy-service.d.ts +18 -4
- package/lib/table/service/copy-service.if.d.ts +4 -3
- package/lib/table/service/data/collapsed-expanded.data.d.ts +1 -0
- package/lib/table/service/data/html-style.type.d.ts +1 -0
- package/lib/table/service/dom-service.if.d.ts +30 -0
- package/lib/table/service/excel-service.d.ts +24 -1
- package/lib/table/service/excel-service.if.d.ts +7 -0
- package/lib/table/service/ge-filter.service.d.ts +1 -0
- package/lib/table/service/simple-dom-service.d.ts +3 -1
- package/lib/table/service/store-state-collapsed-expand.service.d.ts +4 -3
- package/lib/table/service/store-state-scroll-pos.service.d.ts +3 -2
- package/lib/table/service/store-state-sorting.service.d.ts +4 -3
- package/lib/table/service/tree-row.service.d.ts +5 -1
- package/lib/table/state/state-storage.if.d.ts +39 -0
- package/lib/table/state/table-state-migration.d.ts +36 -0
- package/lib/table/state/table-state-part.d.ts +13 -0
- package/lib/table/state/table-state.if.d.ts +181 -0
- package/lib/table/state/table-state.service.d.ts +158 -0
- package/lib/table/table-api.d.ts +450 -550
- package/lib/table/table-scope.d.ts +288 -114
- package/package.json +23 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AbstractAreaModel } from './abstract-area-model';
|
|
2
|
-
import { ColumnDefIf } from '../column/column-def.if';
|
|
3
|
-
import { AreaIdent } from '../area-ident.type';
|
|
4
|
-
import { FilterFunction } from '../../common/filter-function';
|
|
5
|
-
import { SorterService } from '../../../service/sorter.service';
|
|
6
|
-
import { SortItem } from '../../common/sort-item';
|
|
7
|
-
import { ObjectArrayHolderIf } from './object-array-holder.if';
|
|
1
|
+
import { AbstractAreaModel } from './abstract-area-model.js';
|
|
2
|
+
import { ColumnDefIf } from '../column/column-def.if.js';
|
|
3
|
+
import { AreaIdent } from '../area-ident.type.js';
|
|
4
|
+
import { FilterFunction } from '../../common/filter-function.js';
|
|
5
|
+
import { SorterService } from '../../../service/sorter.service.js';
|
|
6
|
+
import { SortItem } from '../../common/sort-item.js';
|
|
7
|
+
import { ObjectArrayHolderIf } from './object-array-holder.if.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @class AreaModelObjectArray
|
|
@@ -35,10 +35,10 @@ import { ObjectArrayHolderIf } from './object-array-holder.if';
|
|
|
35
35
|
* { id: 3, name: 'Bob', age: 40 }
|
|
36
36
|
* ];
|
|
37
37
|
*
|
|
38
|
-
* const columnDefs = [
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* const columnDefs: ColumnDefIf[] = [
|
|
39
|
+
* new ColumnDef('id', 'ID', new Size(50, 'px')),
|
|
40
|
+
* new ColumnDef('name', 'Name', new Size(150, 'px')),
|
|
41
|
+
* new ColumnDef('age', 'Age', new Size(100, 'px'))
|
|
42
42
|
* ];
|
|
43
43
|
*
|
|
44
44
|
* const bodyAreaModel = new AreaModelObjectArray<any>(
|
|
@@ -50,7 +50,7 @@ import { ObjectArrayHolderIf } from './object-array-holder.if';
|
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* // Using with TableFactory to create a complete table model
|
|
53
|
-
* import { TableFactory } from '../../../factory/table-factory';
|
|
53
|
+
* import { TableFactory } from '../../../factory/table-factory.js';
|
|
54
54
|
*
|
|
55
55
|
* const rows = [
|
|
56
56
|
* { id: 1, name: 'John', age: 30 },
|
|
@@ -58,10 +58,10 @@ import { ObjectArrayHolderIf } from './object-array-holder.if';
|
|
|
58
58
|
* { id: 3, name: 'Bob', age: 40 }
|
|
59
59
|
* ];
|
|
60
60
|
*
|
|
61
|
-
* const columnDefs = [
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
61
|
+
* const columnDefs: ColumnDefIf[] = [
|
|
62
|
+
* new ColumnDef('id', 'ID', new Size(50, 'px')),
|
|
63
|
+
* new ColumnDef('name', 'Name', new Size(150, 'px')),
|
|
64
|
+
* new ColumnDef('age', 'Age', new Size(100, 'px'))
|
|
65
65
|
* ];
|
|
66
66
|
*
|
|
67
67
|
* const tableModel = TableFactory.createByObjectArray(
|
|
@@ -82,11 +82,11 @@ import { ObjectArrayHolderIf } from './object-array-holder.if';
|
|
|
82
82
|
* { id: 2, person: { name: 'Jane', contact: { email: 'jane@example.com', phone: '098-765-4321' } } }
|
|
83
83
|
* ];
|
|
84
84
|
*
|
|
85
|
-
* const columnDefs = [
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
85
|
+
* const columnDefs: ColumnDefIf[] = [
|
|
86
|
+
* new ColumnDef('id', 'ID', new Size(50, 'px')),
|
|
87
|
+
* new ColumnDef('person.name', 'Name', new Size(150, 'px')),
|
|
88
|
+
* new ColumnDef('person.contact.email', 'Email', new Size(200, 'px')),
|
|
89
|
+
* new ColumnDef('person.contact.phone', 'Phone', new Size(150, 'px'))
|
|
90
90
|
* ];
|
|
91
91
|
*
|
|
92
92
|
* const bodyAreaModel = new AreaModelObjectArray<any>(
|
|
@@ -139,6 +139,8 @@ import { ObjectArrayHolderIf } from './object-array-holder.if';
|
|
|
139
139
|
* @see {@link AbstractAreaModel} - The parent class that provides the base implementation
|
|
140
140
|
* @see {@link ObjectArrayHolderIf} - The interface that defines methods for accessing rows
|
|
141
141
|
* @see {@link AreaModelObjectArrayWithColumndefs} - A subclass that changes the constructor parameter order
|
|
142
|
+
*
|
|
143
|
+
* @category Area models
|
|
142
144
|
*/
|
|
143
145
|
export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implements ObjectArrayHolderIf<T> {
|
|
144
146
|
areaIdent: AreaIdent;
|
|
@@ -166,6 +168,7 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
166
168
|
* Service for handling sorting operations.
|
|
167
169
|
* @protected
|
|
168
170
|
* @type {SorterService}
|
|
171
|
+
* @internal
|
|
169
172
|
*/
|
|
170
173
|
protected sorterService: SorterService;
|
|
171
174
|
/**
|
|
@@ -184,10 +187,10 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
184
187
|
* { id: 2, name: 'Jane', age: 25 }
|
|
185
188
|
* ];
|
|
186
189
|
*
|
|
187
|
-
* const columnDefs = [
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
190
|
+
* const columnDefs: ColumnDefIf[] = [
|
|
191
|
+
* new ColumnDef('id', 'ID', new Size(50, 'px')),
|
|
192
|
+
* new ColumnDef('name', 'Name', new Size(150, 'px')),
|
|
193
|
+
* new ColumnDef('age', 'Age', new Size(100, 'px'))
|
|
191
194
|
* ];
|
|
192
195
|
*
|
|
193
196
|
* const bodyAreaModel = new AreaModelObjectArray(
|
|
@@ -264,6 +267,19 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
264
267
|
* console.log(`The table has ${rowCount} rows`);
|
|
265
268
|
*/
|
|
266
269
|
getRowCount(): number;
|
|
270
|
+
/**
|
|
271
|
+
* The number of all rows, without the external filter (the filter only shrinks {@link getRowCount}).
|
|
272
|
+
*
|
|
273
|
+
* @returns {number} `getAllRows().length`
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* if (bodyAreaModel.getRowCount() === 0 && bodyAreaModel.getUnfilteredRowCount() > 0) {
|
|
277
|
+
* console.log("The filter hides all rows");
|
|
278
|
+
* }
|
|
279
|
+
*
|
|
280
|
+
* @since 1.1.92
|
|
281
|
+
*/
|
|
282
|
+
getUnfilteredRowCount(): number;
|
|
267
283
|
/**
|
|
268
284
|
* Gets the value at the specified row and column indices.
|
|
269
285
|
* This method handles tree rows and nested properties.
|
|
@@ -432,7 +448,8 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
432
448
|
externalFilterChanged(predictFn: FilterFunction<any>): void;
|
|
433
449
|
/**
|
|
434
450
|
* Sorts the filtered rows based on the provided sort items.
|
|
435
|
-
* This method supports sorting by multiple columns with different sort directions
|
|
451
|
+
* This method supports sorting by multiple columns with different sort directions: the first item is the primary
|
|
452
|
+
* key, the following ones break ties.
|
|
436
453
|
*
|
|
437
454
|
* @param {SortItem[]} sortItems - An array of sort items, each containing a column index and sort state
|
|
438
455
|
* @returns {boolean} Always returns true to indicate sorting was performed
|
|
@@ -450,7 +467,7 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
450
467
|
*
|
|
451
468
|
* @example
|
|
452
469
|
* // Clear sorting
|
|
453
|
-
* bodyAreaModel.doSort([
|
|
470
|
+
* bodyAreaModel.doSort([new SortItem(0, '')]);
|
|
454
471
|
*/
|
|
455
472
|
doSort(sortItems: SortItem[]): boolean;
|
|
456
473
|
/**
|
|
@@ -508,7 +525,7 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
508
525
|
*
|
|
509
526
|
* @example
|
|
510
527
|
* // Move the last column to the first position
|
|
511
|
-
* const lastIndex =
|
|
528
|
+
* const lastIndex = tableModel.getColumnCount() - 1;
|
|
512
529
|
* bodyAreaModel.changeColumnOrder(lastIndex, 0);
|
|
513
530
|
*/
|
|
514
531
|
changeColumnOrder(sourceColumnIndex: number, targetColumnIndex: number): void;
|
|
@@ -541,11 +558,11 @@ export declare class AreaModelObjectArray<T> extends AbstractAreaModel<T> implem
|
|
|
541
558
|
* @returns {(a: T, b: T) => number} A comparator function that compares two rows
|
|
542
559
|
*
|
|
543
560
|
* @example
|
|
544
|
-
* //
|
|
545
|
-
* const comparator =
|
|
561
|
+
* // inside a subclass: a comparator for sorting by name in ascending order
|
|
562
|
+
* const comparator = this.genericFlatTableSortComparator('name', 1);
|
|
546
563
|
*
|
|
547
564
|
* // Sort the rows using the comparator
|
|
548
|
-
* const sortedRows = [...
|
|
565
|
+
* const sortedRows = [...this.getFilteredRows()].sort(comparator);
|
|
549
566
|
*/
|
|
550
567
|
protected genericFlatTableSortComparator(property: string, f: number): (a: T, b: T) => number;
|
|
551
568
|
/**
|
|
@@ -1,17 +1,44 @@
|
|
|
1
|
-
import { TreeRow } from '../../common/tree-row';
|
|
2
|
-
import { AbstractAreaModel } from './abstract-area-model';
|
|
3
|
-
import { AreaIdent } from '../area-ident.type';
|
|
4
|
-
import { ColumnDefIf } from '../column/column-def.if';
|
|
5
|
-
import { FilterFunction } from '../../common/filter-function';
|
|
6
|
-
import { SorterService } from '../../../service/sorter.service';
|
|
7
|
-
import { SortItem } from '../../common/sort-item';
|
|
8
|
-
import { TreeRowIf } from '../../common/tree-row-if';
|
|
1
|
+
import { TreeRow } from '../../common/tree-row.js';
|
|
2
|
+
import { AbstractAreaModel } from './abstract-area-model.js';
|
|
3
|
+
import { AreaIdent } from '../area-ident.type.js';
|
|
4
|
+
import { ColumnDefIf } from '../column/column-def.if.js';
|
|
5
|
+
import { FilterFunction } from '../../common/filter-function.js';
|
|
6
|
+
import { SorterService } from '../../../service/sorter.service.js';
|
|
7
|
+
import { SortItem } from '../../common/sort-item.js';
|
|
8
|
+
import { TreeRowIf } from '../../common/tree-row-if.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Represents a tree-based table model.
|
|
12
12
|
* Extends the AbstractAreaModel class.
|
|
13
13
|
*
|
|
14
|
+
* The displayed rows always come from one pipeline: all tree rows (in their current, possibly sorted order)
|
|
15
|
+
* → rows whose parents are all expanded → active filter. Everything that changes one of these inputs
|
|
16
|
+
* ({@link recalcVisibleTreeRows} after an expand/collapse, {@link externalFilterChanged}, {@link doSort},
|
|
17
|
+
* {@link toggleExpandCollapseAll}) runs the whole pipeline, so a filter survives expanding, collapsing and sorting.
|
|
18
|
+
*
|
|
19
|
+
* Filter semantics: the filter function receives the {@link TreeRowIf tree row} – your object is `row.data`.
|
|
20
|
+
* It is called for **every** row, also for rows below collapsed parents. A row is shown if it or one of its
|
|
21
|
+
* descendants matches (`row.keep`) and all its parents are expanded. So a match below a collapsed node keeps
|
|
22
|
+
* that node visible (still collapsed); expanding it reveals the path to the match. The children of a matching
|
|
23
|
+
* row are not kept automatically.
|
|
24
|
+
*
|
|
14
25
|
* @template S - The type of the row data.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // a tree table with a live search over the labels
|
|
29
|
+
* const filter = { text: "" };
|
|
30
|
+
* const tableOptions: TableOptionsIf = {
|
|
31
|
+
* ...new TableOptions(),
|
|
32
|
+
* externalFilterFunction: (row: TreeRowIf<OrderNode>) => row.data.label.toLowerCase().includes(filter.text)
|
|
33
|
+
* };
|
|
34
|
+
* const rows = TreeFactory.buildTreeRows<OrderNode>(nodes, { expanded: false });
|
|
35
|
+
* const tableModel = TableFactory.createTableModel({ rows, columnDefs, tableOptions });
|
|
36
|
+
* searchInput.addEventListener("input", () => {
|
|
37
|
+
* filter.text = searchInput.value.toLowerCase();
|
|
38
|
+
* tableApi.externalFilterChanged(); // parents of matches stay visible; expanding and sorting keep the filter
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* @category Tree & checkboxes
|
|
15
42
|
*/
|
|
16
43
|
export declare class AreaModelTree<S> extends AbstractAreaModel<TreeRow<S>> {
|
|
17
44
|
areaIdent: AreaIdent;
|
|
@@ -20,16 +47,81 @@ export declare class AreaModelTree<S> extends AbstractAreaModel<TreeRow<S>> {
|
|
|
20
47
|
protected columnDefs: ColumnDefIf[];
|
|
21
48
|
type: string;
|
|
22
49
|
protected readonly properties: string[];
|
|
50
|
+
/** @internal */
|
|
23
51
|
protected sorterService: SorterService;
|
|
24
52
|
private readonly service;
|
|
53
|
+
/** the displayed rows: all parents expanded and accepted by the filter */
|
|
25
54
|
private filteredFlattenRows;
|
|
55
|
+
/** the visible rows (all parents expanded), not filtered */
|
|
26
56
|
private flattenRows;
|
|
27
57
|
private lastPredictFn?;
|
|
58
|
+
/** `row.keep` was set for the current filter (it depends on the filter and the data, not on expand/collapse). */
|
|
59
|
+
private keepMarked;
|
|
28
60
|
constructor(areaIdent: AreaIdent, rows: TreeRowIf<S>[], defaultRowHeight: number, columnDefs?: ColumnDefIf[]);
|
|
29
61
|
changeColumnOrder(sourceColumnIndex: number, targetColumnIndex: number): void;
|
|
30
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Rebuilds the displayed rows after the `expanded` state of rows has changed and applies the active filter
|
|
64
|
+
* (see {@link externalFilterChanged}) again. The table calls it on every expand/collapse click. Call it
|
|
65
|
+
* yourself after changing `row.expanded` from code, then repaint with `tableApi.repaintHard()`
|
|
66
|
+
* (the row count changes).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // expand all first-level rows from code
|
|
70
|
+
* const treeModel = tableModel.getBodyModel() as AreaModelTree<OrderNode>;
|
|
71
|
+
* for (const row of treeModel.rows) row.expanded = true;
|
|
72
|
+
* treeModel.recalcVisibleTreeRows();
|
|
73
|
+
* tableApi.repaintHard();
|
|
74
|
+
*
|
|
75
|
+
* @param {boolean} [refilter=true] - run the filter function again (needed after the rows changed). `false` after a
|
|
76
|
+
* pure expand/collapse: whether a row matches does not depend on it (the table does this on every click –
|
|
77
|
+
* before, the filter ran over all nodes for each click).
|
|
78
|
+
*/
|
|
79
|
+
recalcVisibleTreeRows(refilter?: boolean): void;
|
|
80
|
+
/**
|
|
81
|
+
* The displayed top-level rows: all of {@link rows}, with an active filter only the matching ones (or with a
|
|
82
|
+
* matching descendant).
|
|
83
|
+
*
|
|
84
|
+
* @returns {TreeRowIf<S>[]} the top-level rows that are shown
|
|
85
|
+
*/
|
|
86
|
+
getDisplayedRootRows(): TreeRowIf<S>[];
|
|
87
|
+
/**
|
|
88
|
+
* True if the row has children that are shown when it is expanded – with an active filter only children that
|
|
89
|
+
* match (or have a matching descendant) count. The arrow of a row without such children is hidden.
|
|
90
|
+
*
|
|
91
|
+
* @param {TreeRowIf<S>} row - a tree row of this model
|
|
92
|
+
* @returns {boolean} true if the row has displayed children
|
|
93
|
+
*/
|
|
94
|
+
hasDisplayedChildren(row: TreeRowIf<S>): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The displayed children of a row (in display order): all children, with an active filter only those that match
|
|
97
|
+
* (or have a matching descendant). They are on screen if the row is expanded.
|
|
98
|
+
* Used for the screen reader attributes `aria-setsize` / `aria-posinset` of tree rows.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const treeModel = tableModel.getBodyModel() as AreaModelTree<OrderNode>;
|
|
102
|
+
* const shown = treeModel.getDisplayedChildren(treeModel.rows[0]).length;
|
|
103
|
+
*
|
|
104
|
+
* @param {TreeRowIf<S>} row - a tree row of this model
|
|
105
|
+
* @returns {TreeRowIf<S>[]} the displayed children (empty for a leaf)
|
|
106
|
+
* @since 1.1.91
|
|
107
|
+
*/
|
|
108
|
+
getDisplayedChildren(row: TreeRowIf<S>): TreeRowIf<S>[];
|
|
109
|
+
/**
|
|
110
|
+
* The displayed rows: all parents expanded and accepted by the active filter, in display order.
|
|
111
|
+
*
|
|
112
|
+
* @returns {TreeRowIf<S>[]} the displayed tree rows (do not modify the array)
|
|
113
|
+
*/
|
|
31
114
|
getFilteredFlattenRows(): TreeRowIf<S>[];
|
|
32
115
|
getRowCount(): number;
|
|
116
|
+
/**
|
|
117
|
+
* The number of rows the tree shows without the external filter: all nodes whose parents are expanded
|
|
118
|
+
* (collapsed children do not count). `0` only for a tree without rows.
|
|
119
|
+
*
|
|
120
|
+
* @returns {number} displayed rows before filtering
|
|
121
|
+
*
|
|
122
|
+
* @since 1.1.92
|
|
123
|
+
*/
|
|
124
|
+
getUnfilteredRowCount(): number;
|
|
33
125
|
getValueAt(rowIndex: number, columnIndex: number): any;
|
|
34
126
|
getRowHeight(_rowIndex: number): number;
|
|
35
127
|
/**
|
|
@@ -42,14 +134,73 @@ export declare class AreaModelTree<S> extends AbstractAreaModel<TreeRow<S>> {
|
|
|
42
134
|
getCustomClassesAt(rowIndex: number, _columnIndex: number): string[];
|
|
43
135
|
getRowByIndex(idx: number): TreeRowIf<S> | undefined;
|
|
44
136
|
getValueByT(t: S, property: string): any;
|
|
137
|
+
/**
|
|
138
|
+
* Filters the tree; the function is remembered and applied again on every expand/collapse
|
|
139
|
+
* ({@link recalcVisibleTreeRows}), {@link toggleExpandCollapseAll} and {@link doSort}.
|
|
140
|
+
*
|
|
141
|
+
* The function is called once for **every** tree row in depth-first order – also for rows below collapsed
|
|
142
|
+
* parents – with the {@link TreeRowIf tree row} (not your object: use `row.data`), the index of the row in
|
|
143
|
+
* this depth-first list and the list itself. Shown are the rows that match or have a matching descendant
|
|
144
|
+
* (`row.keep = true`) and whose parents are all expanded. A match below a collapsed node therefore keeps the
|
|
145
|
+
* collapsed node visible. Usually called by `tableApi.externalFilterChanged()` with
|
|
146
|
+
* `tableOptions.externalFilterFunction`.
|
|
147
|
+
*
|
|
148
|
+
* @param {FilterFunction<S>} predictFn - returns a truthy value for the rows to show
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* const treeModel = tableModel.getBodyModel() as AreaModelTree<OrderNode>;
|
|
152
|
+
* treeModel.externalFilterChanged((row: TreeRowIf<OrderNode>) => row.data.total > 1000);
|
|
153
|
+
* tableApi.repaintHard();
|
|
154
|
+
*
|
|
155
|
+
* // remove the filter
|
|
156
|
+
* treeModel.externalFilterChanged(() => true);
|
|
157
|
+
*/
|
|
45
158
|
externalFilterChanged<S>(predictFn: FilterFunction<S>): void;
|
|
159
|
+
/**
|
|
160
|
+
* Sorts the rows of every level (children stay below their parent) and keeps the active filter. The first sort
|
|
161
|
+
* item is the primary key, the following ones break ties. The `rows` array and the children arrays are reordered
|
|
162
|
+
* in place, so the order survives expanding, collapsing and filtering. Sort state `""` keeps the current order.
|
|
163
|
+
*
|
|
164
|
+
* @param {SortItem[]} sortItems - primary key first; an empty list does nothing
|
|
165
|
+
* @returns {boolean} `true` if the rows were sorted, `false` for an empty list
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* tableModel.getBodyModel().doSort([new SortItem(1, "desc")]);
|
|
169
|
+
* tableApi.repaint();
|
|
170
|
+
*/
|
|
46
171
|
doSort(sortItems: SortItem[]): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Sorts the rows of every level with your own function (children stay below their parent) and keeps the active
|
|
174
|
+
* filter. Used by `tableApi.sort(fn)` – before, sorting a tree with a function did nothing.
|
|
175
|
+
*
|
|
176
|
+
* @param {(a: TreeRowIf<S>, b: TreeRowIf<S>) => number} compareFn - compares two sibling rows – like the filter
|
|
177
|
+
* function it gets the tree rows: your objects are `a.data` / `b.data`
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* tableApi.sort((a, b) => a.data.total - b.data.total); // sorts the siblings of every level by total
|
|
181
|
+
*/
|
|
182
|
+
sort(compareFn: (a: TreeRowIf<S>, b: TreeRowIf<S>) => number): void;
|
|
183
|
+
/**
|
|
184
|
+
* Expands or collapses every row on every level and applies the active filter again.
|
|
185
|
+
*
|
|
186
|
+
* @param {boolean} expanded - `true` expands, `false` collapses all rows
|
|
187
|
+
*/
|
|
47
188
|
toggleExpandCollapseAll(expanded: boolean): void;
|
|
48
189
|
setAllParentsOk(item: TreeRowIf<any>): boolean;
|
|
49
190
|
setValue(rowIndex: number, columnIndex: number, value: any): boolean;
|
|
50
191
|
protected genericTreeTableSortComparator(property: string, f: number): (a: TreeRowIf<S>, b: TreeRowIf<S>) => number;
|
|
51
192
|
private expandAllRecursive;
|
|
52
|
-
|
|
193
|
+
/**
|
|
194
|
+
* The one pipeline behind the displayed rows: all rows (current order) → visible (all parents expanded)
|
|
195
|
+
* → active filter.
|
|
196
|
+
*/
|
|
197
|
+
private refreshDisplayedRows;
|
|
198
|
+
/**
|
|
199
|
+
* Sets `keep` on every row (also below collapsed parents): true for matching rows and all their ancestors.
|
|
200
|
+
*/
|
|
201
|
+
private markKeptRows;
|
|
202
|
+
/** all rows depth-first, independent of the expanded state */
|
|
203
|
+
private collectAllRows;
|
|
53
204
|
private getPropertyValue;
|
|
54
|
-
private
|
|
205
|
+
private treeSortWith;
|
|
55
206
|
}
|
|
@@ -1,96 +1,59 @@
|
|
|
1
|
-
import { AreaModelIf } from './area-model.if';
|
|
2
|
-
import { AreaIdent } from '../area-ident.type';
|
|
3
|
-
import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if';
|
|
4
|
-
import { SortItem } from '../../common/sort-item';
|
|
5
|
-
import { FilterFunction } from '../../common/filter-function';
|
|
6
|
-
import { CellRendererIf } from '../../../renderer/cell-render.if';
|
|
7
|
-
import { CheckedType } from '../../common/checked-type';
|
|
1
|
+
import { AreaModelIf } from './area-model.if.js';
|
|
2
|
+
import { AreaIdent } from '../area-ident.type.js';
|
|
3
|
+
import { CheckboxModelIf } from '../../../checkbox/checkbox-model.if.js';
|
|
4
|
+
import { SortItem } from '../../common/sort-item.js';
|
|
5
|
+
import { FilterFunction } from '../../common/filter-function.js';
|
|
6
|
+
import { CellRendererIf } from '../../../renderer/cell-render.if.js';
|
|
7
|
+
import { CheckedType } from '../../common/checked-type.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @description
|
|
13
|
-
* The AreaModel class is a base implementation of the AreaModelIf interface.
|
|
14
|
-
* It represents a model for a specific area of a table (header, body, or footer)
|
|
15
|
-
* and provides methods for accessing and manipulating data within that area.
|
|
10
|
+
* Base class for area models of your own – every method of {@link AreaModelIf} has a sensible default,
|
|
11
|
+
* override only what you need (at least {@link getRowCount}, {@link getValueAt} and {@link getRowHeight}).
|
|
16
12
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - Footer: Contains summary information or additional controls
|
|
21
|
-
*
|
|
22
|
-
* Each of these areas can be further divided into three sections:
|
|
23
|
-
* - West: Fixed columns on the left side
|
|
24
|
-
* - Center: Scrollable columns in the middle
|
|
25
|
-
* - East: Fixed columns on the right side
|
|
26
|
-
*
|
|
27
|
-
* <pre>
|
|
28
|
-
* +----------------+-------------------+--------------+
|
|
29
|
-
* | header/west | header/center | header/east |
|
|
30
|
-
* +----------------+-------------------+--------------+
|
|
31
|
-
* | body/west | body/center | body/east |
|
|
32
|
-
* +----------------+-------------------+--------------+
|
|
33
|
-
* | footer/west | footer/center | footer/east |
|
|
34
|
-
* +----------------+-------------------+--------------+
|
|
35
|
-
* </pre>
|
|
36
|
-
*
|
|
37
|
-
* This base AreaModel class provides default implementations for all methods
|
|
38
|
-
* required by the AreaModelIf interface. Most methods return default values
|
|
39
|
-
* or do nothing, making this class suitable as a starting point for creating
|
|
40
|
-
* more specialized area models.
|
|
13
|
+
* A table consists of three area models – header, body and footer ({@link AreaIdent}) – and asks them only for
|
|
14
|
+
* the cells that are visible. That makes models possible that compute values on demand (millions of rows,
|
|
15
|
+
* server data) or summarise other models (footer totals).
|
|
41
16
|
*
|
|
42
17
|
* @example
|
|
43
|
-
* //
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* // Extending AreaModel to create a custom implementation
|
|
49
|
-
* class CustomAreaModel extends AreaModel {
|
|
50
|
-
* private data: any[][];
|
|
51
|
-
*
|
|
52
|
-
* constructor(data: any[][]) {
|
|
18
|
+
* // a body with two million rows – no array behind it
|
|
19
|
+
* class TwoMillionRows extends AreaModel {
|
|
20
|
+
* constructor() {
|
|
53
21
|
* super();
|
|
54
|
-
* this.
|
|
22
|
+
* this.areaIdent = "body";
|
|
55
23
|
* }
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* getValueAt(rowIndex: number, columnIndex: number): any {
|
|
62
|
-
* if (rowIndex < 0 || rowIndex >= this.data.length) return undefined;
|
|
63
|
-
* const row = this.data[rowIndex];
|
|
64
|
-
* if (columnIndex < 0 || columnIndex >= row.length) return undefined;
|
|
65
|
-
* return row[columnIndex];
|
|
24
|
+
* override getRowCount(): number { return 2_000_000; }
|
|
25
|
+
* override getRowHeight(_rowIndex: number): number { return 34; }
|
|
26
|
+
* override getConstantRowHeight(): number { return 34; } // all rows equally high → O(1) scrolling
|
|
27
|
+
* override getValueAt(row: number, col: number): any {
|
|
28
|
+
* return col === 0 ? row + 1 : `cell ${row}/${col}`;
|
|
66
29
|
* }
|
|
67
|
-
*
|
|
68
|
-
* // Override other methods as needed...
|
|
69
30
|
* }
|
|
31
|
+
* const tableModel = TableFactory.createTableModel({
|
|
32
|
+
* bodyAreaModel: new TwoMillionRows(),
|
|
33
|
+
* columnDefs: [new ColumnDef("id", "ID", px100, allRight), new ColumnDef("text", "Text", px200)]
|
|
34
|
+
* });
|
|
70
35
|
*
|
|
71
36
|
* @example
|
|
72
|
-
* //
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
37
|
+
* // a footer that sums the rows the body currently shows (after filter and sorting)
|
|
38
|
+
* class TotalsFooter extends AreaModel {
|
|
39
|
+
* constructor(private readonly getBody: () => AreaModelObjectArray<Order>) {
|
|
40
|
+
* super();
|
|
41
|
+
* this.areaIdent = "footer";
|
|
42
|
+
* }
|
|
43
|
+
* override getRowCount(): number { return 1; }
|
|
44
|
+
* override getRowHeight(_rowIndex: number): number { return 34; }
|
|
45
|
+
* override getValueAt(_row: number, col: number): any {
|
|
46
|
+
* const rows = this.getBody().getFilteredRows();
|
|
47
|
+
* return col === 0 ? `${rows.length} orders` : col === 5 ? rows.reduce((s, o) => s + o.total, 0) : "";
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
82
50
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* [
|
|
86
|
-
* [
|
|
87
|
-
* ]);
|
|
88
|
-
* bodyModel.areaIdent = "body";
|
|
89
|
-
* tableModel.setAreaModel("body", bodyModel);
|
|
51
|
+
* @see {@link AreaModelObjectArray} (objects), {@link AreaModelArrayOfArrays} (rows of values), {@link AreaModelTree} (trees)
|
|
52
|
+
* @see Training: [The TableModel: three times three areas](https://gui.expert/training/table-model-areas/),
|
|
53
|
+
* [Own AreaModel: two million rows](https://gui.expert/training/custom-area-model/),
|
|
54
|
+
* [Footer totals](https://gui.expert/training/footer-totals/)
|
|
90
55
|
*
|
|
91
|
-
* @
|
|
92
|
-
* @see {@link AbstractAreaModel} - An abstract implementation with common functionality
|
|
93
|
-
* @see {@link AreaModelObjectArray} - An implementation for object array data
|
|
56
|
+
* @category Area models
|
|
94
57
|
*/
|
|
95
58
|
export declare class AreaModel implements AreaModelIf {
|
|
96
59
|
/**
|
|
@@ -141,31 +104,29 @@ export declare class AreaModel implements AreaModelIf {
|
|
|
141
104
|
changeColumnOrder(_sourceColumnIndex: number, _targetColumnIndex: number): void;
|
|
142
105
|
/**
|
|
143
106
|
* Sorts the rows in this area based on the provided sort items.
|
|
144
|
-
*
|
|
107
|
+
* Called when the user double-clicks a sortable column header (and by {@link TableApi.sortByColumn}).
|
|
145
108
|
* The base implementation returns false (no sorting performed) and should be
|
|
146
|
-
* overridden by subclasses that
|
|
109
|
+
* overridden by subclasses that hold their rows themselves.
|
|
147
110
|
*
|
|
148
111
|
* @param {SortItem[]} _sortItems - An array of sort items, each containing a column index and sort direction
|
|
149
112
|
* @returns {boolean} True if sorting was performed, false otherwise
|
|
150
113
|
*
|
|
151
114
|
* @example
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
115
|
+
* class SortableRows extends AreaModel {
|
|
116
|
+
* constructor(private readonly rows: any[][]) {
|
|
117
|
+
* super();
|
|
118
|
+
* this.areaIdent = "body";
|
|
119
|
+
* }
|
|
120
|
+
* override getRowCount(): number { return this.rows.length; }
|
|
121
|
+
* override getValueAt(row: number, col: number): any { return this.rows[row][col]; }
|
|
155
122
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
123
|
+
* override doSort(sortItems: SortItem[]): boolean {
|
|
124
|
+
* if (!sortItems.length) return false;
|
|
158
125
|
* const { columnIndex, sortState } = sortItems[0];
|
|
159
|
-
* const
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* if (valueA < valueB) return -1 * direction;
|
|
164
|
-
* if (valueA > valueB) return 1 * direction;
|
|
165
|
-
* return 0;
|
|
166
|
-
* });
|
|
167
|
-
*
|
|
168
|
-
* return true;
|
|
126
|
+
* const direction = sortState === "asc" ? 1 : -1;
|
|
127
|
+
* this.rows.sort((a, b) => (a[columnIndex] < b[columnIndex] ? -1 : a[columnIndex] > b[columnIndex] ? 1 : 0) * direction);
|
|
128
|
+
* return true;
|
|
129
|
+
* }
|
|
169
130
|
* }
|
|
170
131
|
*/
|
|
171
132
|
doSort(_sortItems: SortItem[]): boolean;
|
|
@@ -641,19 +602,20 @@ export declare class AreaModel implements AreaModelIf {
|
|
|
641
602
|
isRowChecked(_rowIndex: number): CheckedType | undefined;
|
|
642
603
|
/**
|
|
643
604
|
* Determines whether the cell at the specified row and column indices is selectable.
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
605
|
+
* The table draws the selection (of the {@link SelectionModel}) only on selectable body cells.
|
|
606
|
+
*
|
|
607
|
+
* Default: `true` – all cells are selectable, like in all built-in area models
|
|
608
|
+
* (up to 1.1.90 the default of `AreaModel` was `false`: a selection on an own model was not drawn).
|
|
609
|
+
* Override it to exclude cells, e.g. a column of row numbers.
|
|
647
610
|
*
|
|
648
611
|
* @param {number} _rowIndex - The index of the row
|
|
649
612
|
* @param {number} _columnIndex - The index of the column
|
|
650
613
|
* @returns {boolean} True if the cell is selectable, false otherwise
|
|
651
614
|
*
|
|
652
615
|
* @example
|
|
653
|
-
* // Override in a subclass
|
|
654
|
-
* isSelectable(
|
|
655
|
-
*
|
|
656
|
-
* return this.areaIdent === 'body';
|
|
616
|
+
* // Override in a subclass: the first column (row numbers) never shows a selection
|
|
617
|
+
* override isSelectable(_rowIndex: number, columnIndex: number): boolean {
|
|
618
|
+
* return columnIndex > 0;
|
|
657
619
|
* }
|
|
658
620
|
*/
|
|
659
621
|
isSelectable(_rowIndex: number, _columnIndex: number): boolean;
|