@guiexpert/table 1.1.79 → 1.1.80
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/index.js +1605 -54
- package/lib/table/data/tablemodel/areamodel/area-model-object-array-with-columndefs.d.ts +106 -2
- package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +489 -4
- package/lib/table/data/tablemodel/areamodel/area-model.d.ts +660 -1
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +782 -69
- package/lib/table/table-api.d.ts +1019 -42
- package/package.json +4 -2
|
@@ -6,37 +6,696 @@ import { FilterFunction } from "../../common/filter-function";
|
|
|
6
6
|
import { CellRendererIf } from "../../../renderer/cell-render.if";
|
|
7
7
|
import { CheckedType } from "../../common/checked-type";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* @class AreaModel
|
|
10
|
+
* @implements {AreaModelIf}
|
|
11
|
+
* @description
|
|
12
|
+
* The AreaModel class is a base implementation of the AreaModelIf interface.
|
|
13
|
+
* It represents a model for a specific area of a table (header, body, or footer)
|
|
14
|
+
* and provides methods for accessing and manipulating data within that area.
|
|
15
|
+
*
|
|
16
|
+
* In the GuiExpert Table library, a table is divided into three main areas:
|
|
17
|
+
* - Header: Contains column titles and optional filter/sort controls
|
|
18
|
+
* - Body: Contains the main data of the table
|
|
19
|
+
* - Footer: Contains summary information or additional controls
|
|
20
|
+
*
|
|
21
|
+
* Each of these areas can be further divided into three sections:
|
|
22
|
+
* - West: Fixed columns on the left side
|
|
23
|
+
* - Center: Scrollable columns in the middle
|
|
24
|
+
* - East: Fixed columns on the right side
|
|
25
|
+
*
|
|
26
|
+
* <pre>
|
|
27
|
+
* +----------------+-------------------+--------------+
|
|
28
|
+
* | header/west | header/center | header/east |
|
|
29
|
+
* +----------------+-------------------+--------------+
|
|
30
|
+
* | body/west | body/center | body/east |
|
|
31
|
+
* +----------------+-------------------+--------------+
|
|
32
|
+
* | footer/west | footer/center | footer/east |
|
|
33
|
+
* +----------------+-------------------+--------------+
|
|
34
|
+
* </pre>
|
|
35
|
+
*
|
|
36
|
+
* This base AreaModel class provides default implementations for all methods
|
|
37
|
+
* required by the AreaModelIf interface. Most methods return default values
|
|
38
|
+
* or do nothing, making this class suitable as a starting point for creating
|
|
39
|
+
* more specialized area models.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Creating a basic area model for the header
|
|
43
|
+
* const headerModel = new AreaModel();
|
|
44
|
+
* headerModel.areaIdent = "header";
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Extending AreaModel to create a custom implementation
|
|
48
|
+
* class CustomAreaModel extends AreaModel {
|
|
49
|
+
* private data: any[][];
|
|
50
|
+
*
|
|
51
|
+
* constructor(data: any[][]) {
|
|
52
|
+
* super();
|
|
53
|
+
* this.data = data;
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* getRowCount(): number {
|
|
57
|
+
* return this.data.length;
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* getValueAt(rowIndex: number, columnIndex: number): any {
|
|
61
|
+
* if (rowIndex < 0 || rowIndex >= this.data.length) return undefined;
|
|
62
|
+
* const row = this.data[rowIndex];
|
|
63
|
+
* if (columnIndex < 0 || columnIndex >= row.length) return undefined;
|
|
64
|
+
* return row[columnIndex];
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* // Override other methods as needed...
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Using AreaModel with a TableModel
|
|
72
|
+
* import { TableFactory, TableModelIf } from "@guiexpert/table";
|
|
73
|
+
*
|
|
74
|
+
* // Create a table model with custom area models
|
|
75
|
+
* const tableModel: TableModelIf = TableFactory.createTableModel();
|
|
76
|
+
*
|
|
77
|
+
* // Set custom area models
|
|
78
|
+
* const headerModel = new CustomAreaModel([["ID", "Name", "Age"]]);
|
|
79
|
+
* headerModel.areaIdent = "header";
|
|
80
|
+
* tableModel.setAreaModel("header", headerModel);
|
|
81
|
+
*
|
|
82
|
+
* const bodyModel = new CustomAreaModel([
|
|
83
|
+
* [1, "John", 30],
|
|
84
|
+
* [2, "Jane", 25],
|
|
85
|
+
* [3, "Bob", 40]
|
|
86
|
+
* ]);
|
|
87
|
+
* bodyModel.areaIdent = "body";
|
|
88
|
+
* tableModel.setAreaModel("body", bodyModel);
|
|
89
|
+
*
|
|
90
|
+
* @see {@link AreaModelIf} - The interface that this class implements
|
|
91
|
+
* @see {@link AbstractAreaModel} - An abstract implementation with common functionality
|
|
92
|
+
* @see {@link AreaModelObjectArray} - An implementation for object array data
|
|
10
93
|
*/
|
|
11
94
|
export declare class AreaModel implements AreaModelIf {
|
|
95
|
+
/**
|
|
96
|
+
* The identifier for one of the areas: header, body, footer.
|
|
97
|
+
* This property determines which area of the table this model represents.
|
|
98
|
+
* Default value is "body".
|
|
99
|
+
*
|
|
100
|
+
* @type {AreaIdent}
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Creating an area model for the header
|
|
104
|
+
* const headerModel = new AreaModel();
|
|
105
|
+
* headerModel.areaIdent = "header";
|
|
106
|
+
*/
|
|
12
107
|
areaIdent: AreaIdent;
|
|
108
|
+
/**
|
|
109
|
+
* A model and controller for row checkbox selection.
|
|
110
|
+
* This property allows the area to support row selection via checkboxes.
|
|
111
|
+
* Default value is undefined (no row selection).
|
|
112
|
+
*
|
|
113
|
+
* @type {CheckboxModelIf<any> | undefined}
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // Creating a checkbox model for row selection
|
|
117
|
+
* import { CheckboxModel } from "@guiexpert/table";
|
|
118
|
+
*
|
|
119
|
+
* const bodyModel = new AreaModel();
|
|
120
|
+
* bodyModel.rowSelectionModel = new CheckboxModel();
|
|
121
|
+
*/
|
|
13
122
|
rowSelectionModel: CheckboxModelIf<any> | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Changes the order of columns by moving a column from one position to another.
|
|
125
|
+
* This method is called when the user drags a column to a new position.
|
|
126
|
+
* The base implementation does nothing and should be overridden by subclasses
|
|
127
|
+
* that support column reordering.
|
|
128
|
+
*
|
|
129
|
+
* @param {number} _sourceColumnIndex - The index of the column to move
|
|
130
|
+
* @param {number} _targetColumnIndex - The index where the column should be moved to
|
|
131
|
+
* @returns {void}
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // Override in a subclass to implement column reordering
|
|
135
|
+
* changeColumnOrder(sourceColumnIndex: number, targetColumnIndex: number): void {
|
|
136
|
+
* // Move the column in the internal data structure
|
|
137
|
+
* this.arrayMove(this.columns, sourceColumnIndex, targetColumnIndex);
|
|
138
|
+
* }
|
|
139
|
+
*/
|
|
14
140
|
changeColumnOrder(_sourceColumnIndex: number, _targetColumnIndex: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Sorts the rows in this area based on the provided sort items.
|
|
143
|
+
* This method is called when the user clicks on a sortable column header.
|
|
144
|
+
* The base implementation returns false (no sorting performed) and should be
|
|
145
|
+
* overridden by subclasses that support sorting.
|
|
146
|
+
*
|
|
147
|
+
* @param {SortItem[]} _sortItems - An array of sort items, each containing a column index and sort direction
|
|
148
|
+
* @returns {boolean} True if sorting was performed, false otherwise
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // Override in a subclass to implement sorting
|
|
152
|
+
* doSort(sortItems: SortItem[]): boolean {
|
|
153
|
+
* if (!sortItems.length) return false;
|
|
154
|
+
*
|
|
155
|
+
* // Apply sorting to the rows
|
|
156
|
+
* this.rows.sort((a, b) => {
|
|
157
|
+
* const { columnIndex, sortState } = sortItems[0];
|
|
158
|
+
* const valueA = this.getValueAt(this.rows.indexOf(a), columnIndex);
|
|
159
|
+
* const valueB = this.getValueAt(this.rows.indexOf(b), columnIndex);
|
|
160
|
+
*
|
|
161
|
+
* const direction = sortState === 'asc' ? 1 : -1;
|
|
162
|
+
* if (valueA < valueB) return -1 * direction;
|
|
163
|
+
* if (valueA > valueB) return 1 * direction;
|
|
164
|
+
* return 0;
|
|
165
|
+
* });
|
|
166
|
+
*
|
|
167
|
+
* return true;
|
|
168
|
+
* }
|
|
169
|
+
*/
|
|
15
170
|
doSort(_sortItems: SortItem[]): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Sorts the rows in this area using a custom comparator function.
|
|
173
|
+
* This method provides more flexibility than doSort for complex sorting logic.
|
|
174
|
+
* The base implementation does nothing and should be overridden by subclasses
|
|
175
|
+
* that support custom sorting.
|
|
176
|
+
*
|
|
177
|
+
* @param {(a: any, b: any) => number} [_compareFn] - A function that compares two rows and returns a number:
|
|
178
|
+
* - Negative if a should come before b
|
|
179
|
+
* - Positive if a should come after b
|
|
180
|
+
* - Zero if they are equivalent for sorting purposes
|
|
181
|
+
* @returns {void}
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Override in a subclass to implement custom sorting
|
|
185
|
+
* sort(compareFn?: (a: any, b: any) => number): void {
|
|
186
|
+
* if (!compareFn) return;
|
|
187
|
+
*
|
|
188
|
+
* // Apply the custom sort function
|
|
189
|
+
* this.rows.sort(compareFn);
|
|
190
|
+
* }
|
|
191
|
+
*/
|
|
16
192
|
sort(_compareFn?: (a: any, b: any) => number): void;
|
|
193
|
+
/**
|
|
194
|
+
* Applies a filter function to the rows in this area.
|
|
195
|
+
* This method is called when a filter is applied to the table.
|
|
196
|
+
* The base implementation does nothing and should be overridden by subclasses
|
|
197
|
+
* that support filtering.
|
|
198
|
+
*
|
|
199
|
+
* @param {FilterFunction<T>} _predictFn - A function that takes a row and returns true if the row should be visible
|
|
200
|
+
* @returns {void}
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* // Override in a subclass to implement filtering
|
|
204
|
+
* externalFilterChanged<T>(predictFn: FilterFunction<T>): void {
|
|
205
|
+
* // Apply the filter to the rows
|
|
206
|
+
* this.filteredRows = this.rows.filter(predictFn);
|
|
207
|
+
* }
|
|
208
|
+
*/
|
|
17
209
|
externalFilterChanged<T>(_predictFn: FilterFunction<T>): void;
|
|
210
|
+
/**
|
|
211
|
+
* Returns a cell renderer for the cell at the specified row and column indices.
|
|
212
|
+
* A cell renderer is responsible for rendering the cell content in a custom way.
|
|
213
|
+
* The base implementation returns undefined (default rendering) and should be
|
|
214
|
+
* overridden by subclasses that support custom cell rendering.
|
|
215
|
+
*
|
|
216
|
+
* @param {number} _rowIndex - The index of the row
|
|
217
|
+
* @param {number} _columnIndex - The index of the column
|
|
218
|
+
* @returns {CellRendererIf | undefined} A cell renderer instance, or undefined for default rendering
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* // Override in a subclass to provide custom cell renderers
|
|
222
|
+
* getCellRenderer(rowIndex: number, columnIndex: number): CellRendererIf | undefined {
|
|
223
|
+
* // Get renderer from column definition
|
|
224
|
+
* const columnDef = this.columnDefs[columnIndex];
|
|
225
|
+
* return columnDef?.rendererMap?.[this.areaIdent];
|
|
226
|
+
* }
|
|
227
|
+
*/
|
|
18
228
|
getCellRenderer(_rowIndex: number, _columnIndex: number): CellRendererIf | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Returns the column span value for the cell at the specified row and column indices.
|
|
231
|
+
* A colspan value of N means the cell spans N columns horizontally.
|
|
232
|
+
* The base implementation returns 0 (no spanning) and should be overridden by
|
|
233
|
+
* subclasses that support column spanning.
|
|
234
|
+
*
|
|
235
|
+
* @param {number} _rowIndex - The index of the row
|
|
236
|
+
* @param {number} _columnIndex - The index of the column
|
|
237
|
+
* @returns {number} The colspan value (number of columns the cell spans)
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* // Override in a subclass to implement column spanning
|
|
241
|
+
* getColspanAt(rowIndex: number, columnIndex: number): number {
|
|
242
|
+
* // Special case: first row, first column spans 3 columns
|
|
243
|
+
* if (rowIndex === 0 && columnIndex === 0) return 3;
|
|
244
|
+
*
|
|
245
|
+
* // No spanning for other cells
|
|
246
|
+
* return 1;
|
|
247
|
+
* }
|
|
248
|
+
*/
|
|
19
249
|
getColspanAt(_rowIndex: number, _columnIndex: number): number;
|
|
250
|
+
/**
|
|
251
|
+
* Returns an array of CSS class names to apply to the cell at the specified row and column indices.
|
|
252
|
+
* This method allows for custom styling of individual cells.
|
|
253
|
+
* The base implementation returns an empty array (no custom classes) and should be
|
|
254
|
+
* overridden by subclasses that support custom cell styling.
|
|
255
|
+
*
|
|
256
|
+
* @param {number} _rowIndex - The index of the row
|
|
257
|
+
* @param {number} _columnIndex - The index of the column
|
|
258
|
+
* @returns {string[]} An array of CSS class names
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // Override in a subclass to implement custom cell classes
|
|
262
|
+
* getCustomClassesAt(rowIndex: number, columnIndex: number): string[] {
|
|
263
|
+
* const classes: string[] = [];
|
|
264
|
+
*
|
|
265
|
+
* // Add classes based on row index
|
|
266
|
+
* if (rowIndex % 2 === 0) {
|
|
267
|
+
* classes.push('even-row');
|
|
268
|
+
* } else {
|
|
269
|
+
* classes.push('odd-row');
|
|
270
|
+
* }
|
|
271
|
+
*
|
|
272
|
+
* // Add classes based on cell value
|
|
273
|
+
* const value = this.getValueAt(rowIndex, columnIndex);
|
|
274
|
+
* if (typeof value === 'number' && value < 0) {
|
|
275
|
+
* classes.push('negative-value');
|
|
276
|
+
* }
|
|
277
|
+
*
|
|
278
|
+
* return classes;
|
|
279
|
+
* }
|
|
280
|
+
*/
|
|
20
281
|
getCustomClassesAt(_rowIndex: number, _columnIndex: number): string[];
|
|
282
|
+
/**
|
|
283
|
+
* Returns an object containing CSS style properties to apply to the cell at the specified row and column indices.
|
|
284
|
+
* This method allows for inline styling of individual cells.
|
|
285
|
+
* The base implementation returns undefined (no custom styles) and should be
|
|
286
|
+
* overridden by subclasses that support custom cell styling.
|
|
287
|
+
*
|
|
288
|
+
* @param {number} _rowIndex - The index of the row
|
|
289
|
+
* @param {number} _columnIndex - The index of the column
|
|
290
|
+
* @returns {{ [key: string]: string } | undefined} An object with CSS style properties, or undefined if no custom styles
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* // Override in a subclass to implement custom cell styles
|
|
294
|
+
* getCustomStyleAt(rowIndex: number, columnIndex: number): { [key: string]: string } | undefined {
|
|
295
|
+
* // Apply background color based on value
|
|
296
|
+
* const value = this.getValueAt(rowIndex, columnIndex);
|
|
297
|
+
*
|
|
298
|
+
* if (typeof value === 'number') {
|
|
299
|
+
* // Color gradient based on value
|
|
300
|
+
* if (value < 0) {
|
|
301
|
+
* return { 'background-color': `rgba(255, 0, 0, ${Math.min(Math.abs(value) / 100, 0.5)})` };
|
|
302
|
+
* } else if (value > 0) {
|
|
303
|
+
* return { 'background-color': `rgba(0, 255, 0, ${Math.min(value / 100, 0.5)})` };
|
|
304
|
+
* }
|
|
305
|
+
* }
|
|
306
|
+
*
|
|
307
|
+
* return undefined; // No custom styles
|
|
308
|
+
* }
|
|
309
|
+
*/
|
|
21
310
|
getCustomStyleAt(_rowIndex: number, _columnIndex: number): {
|
|
22
311
|
[p: string]: string;
|
|
23
312
|
} | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* Returns the maximum colspan value that can occur in this area model.
|
|
315
|
+
* This value is used to optimize rendering performance.
|
|
316
|
+
* The base implementation returns 0 (no colspans) and should be overridden by
|
|
317
|
+
* subclasses that support column spanning.
|
|
318
|
+
*
|
|
319
|
+
* @returns {number} The maximum possible colspan value in this area
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* // Override in a subclass to specify maximum colspan
|
|
323
|
+
* getMaxColspan(): number {
|
|
324
|
+
* // If the model has colspans, return the maximum possible value
|
|
325
|
+
* return 3; // If some cells span up to 3 columns
|
|
326
|
+
* }
|
|
327
|
+
*/
|
|
24
328
|
getMaxColspan(): number;
|
|
329
|
+
/**
|
|
330
|
+
* Returns the maximum rowspan value that can occur in this area model.
|
|
331
|
+
* This value is used to optimize rendering performance.
|
|
332
|
+
* The base implementation returns 0 (no rowspans) and should be overridden by
|
|
333
|
+
* subclasses that support row spanning.
|
|
334
|
+
*
|
|
335
|
+
* @returns {number} The maximum possible rowspan value in this area
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* // Override in a subclass to specify maximum rowspan
|
|
339
|
+
* getMaxRowspan(): number {
|
|
340
|
+
* // If the model has rowspans, return the maximum possible value
|
|
341
|
+
* return 2; // If some cells span up to 2 rows
|
|
342
|
+
* }
|
|
343
|
+
*/
|
|
25
344
|
getMaxRowspan(): number;
|
|
345
|
+
/**
|
|
346
|
+
* Returns the row object at the specified index.
|
|
347
|
+
* This method provides access to the underlying data structure.
|
|
348
|
+
* The base implementation returns undefined and should be overridden by
|
|
349
|
+
* subclasses that have a row-based data structure.
|
|
350
|
+
*
|
|
351
|
+
* @param {number} _rowIndex - The index of the row
|
|
352
|
+
* @returns {any} The row object, or undefined if the row doesn't exist
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* // Override in a subclass to provide access to row data
|
|
356
|
+
* getRowByIndex(rowIndex: number): any {
|
|
357
|
+
* if (rowIndex < 0 || rowIndex >= this.data.length) return undefined;
|
|
358
|
+
* return this.data[rowIndex];
|
|
359
|
+
* }
|
|
360
|
+
*/
|
|
26
361
|
getRowByIndex(_rowIndex: number): any;
|
|
362
|
+
/**
|
|
363
|
+
* Returns the number of rows in this area.
|
|
364
|
+
* This is a fundamental method that determines the vertical size of the area.
|
|
365
|
+
* The base implementation returns 0 (no rows) and should be overridden by
|
|
366
|
+
* all subclasses.
|
|
367
|
+
*
|
|
368
|
+
* @returns {number} The number of rows in the area
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* // Override in a subclass to provide the row count
|
|
372
|
+
* getRowCount(): number {
|
|
373
|
+
* return this.data.length;
|
|
374
|
+
* }
|
|
375
|
+
*/
|
|
27
376
|
getRowCount(): number;
|
|
377
|
+
/**
|
|
378
|
+
* Returns the height of the row at the specified index, in pixels.
|
|
379
|
+
* This method allows for variable row heights in the table.
|
|
380
|
+
* The base implementation returns 0 and should be overridden by
|
|
381
|
+
* all subclasses.
|
|
382
|
+
*
|
|
383
|
+
* @param {number} _rowIndex - The index of the row
|
|
384
|
+
* @returns {number} The height of the row in pixels
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* // Override in a subclass to provide fixed row heights
|
|
388
|
+
* getRowHeight(rowIndex: number): number {
|
|
389
|
+
* return 30; // 30px for all rows
|
|
390
|
+
* }
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Override in a subclass to provide variable row heights
|
|
394
|
+
* getRowHeight(rowIndex: number): number {
|
|
395
|
+
* // First row is taller
|
|
396
|
+
* if (rowIndex === 0) return 50;
|
|
397
|
+
*
|
|
398
|
+
* // Default height for other rows
|
|
399
|
+
* return 30;
|
|
400
|
+
* }
|
|
401
|
+
*/
|
|
28
402
|
getRowHeight(_rowIndex: number): number;
|
|
403
|
+
/**
|
|
404
|
+
* Returns the row span value for the cell at the specified row and column indices.
|
|
405
|
+
* A rowspan value of N means the cell spans N rows vertically.
|
|
406
|
+
* The base implementation returns 0 (no spanning) and should be overridden by
|
|
407
|
+
* subclasses that support row spanning.
|
|
408
|
+
*
|
|
409
|
+
* @param {number} _rowIndex - The index of the row
|
|
410
|
+
* @param {number} _columnIndex - The index of the column
|
|
411
|
+
* @returns {number} The rowspan value (number of rows the cell spans)
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* // Override in a subclass to implement row spanning
|
|
415
|
+
* getRowspanAt(rowIndex: number, columnIndex: number): number {
|
|
416
|
+
* // Special case: first column spans 2 rows at the beginning
|
|
417
|
+
* if (columnIndex === 0 && rowIndex % 2 === 0) return 2;
|
|
418
|
+
*
|
|
419
|
+
* // No spanning for other cells
|
|
420
|
+
* return 1;
|
|
421
|
+
* }
|
|
422
|
+
*/
|
|
29
423
|
getRowspanAt(_rowIndex: number, _columnIndex: number): number;
|
|
424
|
+
/**
|
|
425
|
+
* Returns the tooltip text for the cell at the specified row and column indices.
|
|
426
|
+
* This tooltip will be displayed when the user hovers over the cell.
|
|
427
|
+
* The base implementation returns undefined (no tooltip) and should be overridden by
|
|
428
|
+
* subclasses that support tooltips.
|
|
429
|
+
*
|
|
430
|
+
* @param {number} _rowIndex - The index of the row
|
|
431
|
+
* @param {number} _columnIndex - The index of the column
|
|
432
|
+
* @returns {any} The tooltip content (usually a string)
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* // Override in a subclass to provide tooltips
|
|
436
|
+
* getTooltipAt(rowIndex: number, columnIndex: number): any {
|
|
437
|
+
* // Use the cell value as the tooltip
|
|
438
|
+
* return this.getValueAt(rowIndex, columnIndex);
|
|
439
|
+
*
|
|
440
|
+
* // Or provide a more detailed tooltip
|
|
441
|
+
* // const value = this.getValueAt(rowIndex, columnIndex);
|
|
442
|
+
* // return `Value: ${value}\nRow: ${rowIndex}\nColumn: ${columnIndex}`;
|
|
443
|
+
* }
|
|
444
|
+
*/
|
|
30
445
|
getTooltipAt(_rowIndex: number, _columnIndex: number): any;
|
|
446
|
+
/**
|
|
447
|
+
* Returns the value of the cell at the specified row and column indices.
|
|
448
|
+
* This is one of the most important methods in the area model, as it provides
|
|
449
|
+
* the actual data to be displayed in each cell.
|
|
450
|
+
* The base implementation returns undefined and should be overridden by
|
|
451
|
+
* all subclasses.
|
|
452
|
+
*
|
|
453
|
+
* @param {number} _rowIndex - The index of the row
|
|
454
|
+
* @param {number} _columnIndex - The index of the column
|
|
455
|
+
* @returns {any} The value at the specified cell
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* // Override in a subclass for a 2D array model
|
|
459
|
+
* getValueAt(rowIndex: number, columnIndex: number): any {
|
|
460
|
+
* if (rowIndex < 0 || rowIndex >= this.data.length) return undefined;
|
|
461
|
+
* const row = this.data[rowIndex];
|
|
462
|
+
* if (columnIndex < 0 || columnIndex >= row.length) return undefined;
|
|
463
|
+
* return row[columnIndex];
|
|
464
|
+
* }
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* // Override in a subclass for an object array model
|
|
468
|
+
* getValueAt(rowIndex: number, columnIndex: number): any {
|
|
469
|
+
* const row = this.getRowByIndex(rowIndex);
|
|
470
|
+
* if (!row) return undefined;
|
|
471
|
+
*
|
|
472
|
+
* const property = this.columnDefs[columnIndex].property;
|
|
473
|
+
* return row[property];
|
|
474
|
+
* }
|
|
475
|
+
*/
|
|
31
476
|
getValueAt(_rowIndex: number, _columnIndex: number): any;
|
|
477
|
+
/**
|
|
478
|
+
* Returns a string representation of the cell value at the specified row and column indices.
|
|
479
|
+
* This method is used when exporting the table data or copying to clipboard.
|
|
480
|
+
* The base implementation returns an empty string and should be overridden by
|
|
481
|
+
* subclasses that need custom text conversion.
|
|
482
|
+
*
|
|
483
|
+
* @param {number} _rowIndex - The index of the row
|
|
484
|
+
* @param {number} _columnIndex - The index of the column
|
|
485
|
+
* @returns {string} The text value of the specified cell
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* // Override in a subclass to provide text representation
|
|
489
|
+
* getTextValueAt(rowIndex: number, columnIndex: number): string {
|
|
490
|
+
* const value = this.getValueAt(rowIndex, columnIndex);
|
|
491
|
+
*
|
|
492
|
+
* // Handle different data types appropriately
|
|
493
|
+
* if (value === null || value === undefined) return '';
|
|
494
|
+
* if (value instanceof Date) return value.toISOString();
|
|
495
|
+
* return String(value);
|
|
496
|
+
* }
|
|
497
|
+
*/
|
|
32
498
|
getTextValueAt(_rowIndex: number, _columnIndex: number): string;
|
|
499
|
+
/**
|
|
500
|
+
* Returns the Y-coordinate (in pixels) of the top of the row at the specified index.
|
|
501
|
+
* This method is used for scrolling and positioning rows in the viewport.
|
|
502
|
+
* The base implementation returns 0 and should be overridden by
|
|
503
|
+
* subclasses that support scrolling.
|
|
504
|
+
*
|
|
505
|
+
* @param {number} _rowIndex - The index of the row
|
|
506
|
+
* @returns {number} The Y-coordinate of the top of the row, in pixels
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* // Override in a subclass with fixed row heights
|
|
510
|
+
* getYPosByRowIndex(rowIndex: number): number {
|
|
511
|
+
* return rowIndex * this.defaultRowHeight;
|
|
512
|
+
* }
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* // Override in a subclass with variable row heights
|
|
516
|
+
* getYPosByRowIndex(rowIndex: number): number {
|
|
517
|
+
* // Use a pre-calculated array of Y-positions
|
|
518
|
+
* return this.yPositions[rowIndex];
|
|
519
|
+
*
|
|
520
|
+
* // Or calculate on-the-fly
|
|
521
|
+
* // let yPos = 0;
|
|
522
|
+
* // for (let i = 0; i < rowIndex; i++) {
|
|
523
|
+
* // yPos += this.getRowHeight(i);
|
|
524
|
+
* // }
|
|
525
|
+
* // return yPos;
|
|
526
|
+
* }
|
|
527
|
+
*/
|
|
33
528
|
getYPosByRowIndex(_rowIndex: number): number;
|
|
529
|
+
/**
|
|
530
|
+
* Initializes the area model.
|
|
531
|
+
* This method is called internally by the TableModel during initialization.
|
|
532
|
+
* It can be used to perform any necessary setup, such as calculating row positions.
|
|
533
|
+
* The base implementation does nothing and can be overridden by
|
|
534
|
+
* subclasses that need initialization.
|
|
535
|
+
*
|
|
536
|
+
* @returns {void}
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* // Override in a subclass to perform initialization
|
|
540
|
+
* init(): void {
|
|
541
|
+
* // Calculate y-positions for all rows
|
|
542
|
+
* this.yPositions = [];
|
|
543
|
+
* let currentY = 0;
|
|
544
|
+
*
|
|
545
|
+
* for (let i = 0; i < this.getRowCount(); i++) {
|
|
546
|
+
* this.yPositions[i] = currentY;
|
|
547
|
+
* currentY += this.getRowHeight(i);
|
|
548
|
+
* }
|
|
549
|
+
* }
|
|
550
|
+
*/
|
|
34
551
|
init(): void;
|
|
552
|
+
/**
|
|
553
|
+
* Determines whether the cell at the specified row and column indices is editable.
|
|
554
|
+
* If true, the user can edit the cell content.
|
|
555
|
+
* The base implementation returns false (not editable) and should be overridden by
|
|
556
|
+
* subclasses that support cell editing.
|
|
557
|
+
*
|
|
558
|
+
* @param {number} _rowIndex - The index of the row
|
|
559
|
+
* @param {number} _columnIndex - The index of the column
|
|
560
|
+
* @returns {boolean} True if the cell is editable, false otherwise
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* // Override in a subclass to implement cell editability
|
|
564
|
+
* isEditable(rowIndex: number, columnIndex: number): boolean {
|
|
565
|
+
* // Header cells are not editable
|
|
566
|
+
* if (this.areaIdent === 'header') return false;
|
|
567
|
+
*
|
|
568
|
+
* // First column is not editable (e.g., ID column)
|
|
569
|
+
* if (columnIndex === 0) return false;
|
|
570
|
+
*
|
|
571
|
+
* // Other cells in the body are editable
|
|
572
|
+
* return this.areaIdent === 'body';
|
|
573
|
+
* }
|
|
574
|
+
*/
|
|
35
575
|
isEditable(_rowIndex: number, _columnIndex: number): boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Determines whether this area supports filtering.
|
|
578
|
+
* If true, the area can be filtered using the externalFilterChanged method.
|
|
579
|
+
* The base implementation returns false (not filterable) and should be overridden by
|
|
580
|
+
* subclasses that support filtering.
|
|
581
|
+
*
|
|
582
|
+
* @returns {boolean} True if the area is filterable, false otherwise
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* // Override in a subclass to enable filtering
|
|
586
|
+
* isFilterable(): boolean {
|
|
587
|
+
* // Only the body area is filterable
|
|
588
|
+
* return this.areaIdent === 'body';
|
|
589
|
+
* }
|
|
590
|
+
*/
|
|
36
591
|
isFilterable(): boolean;
|
|
592
|
+
/**
|
|
593
|
+
* Determines whether the row at the specified index is checkable.
|
|
594
|
+
* If true, a checkbox will be rendered at the beginning of the row.
|
|
595
|
+
* The base implementation returns false (not checkable) and should be overridden by
|
|
596
|
+
* subclasses that support row selection.
|
|
597
|
+
*
|
|
598
|
+
* @param {number} _rowIndex - The index of the row
|
|
599
|
+
* @returns {boolean} True if the row is checkable, false otherwise
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* // Override in a subclass to implement row checkability
|
|
603
|
+
* isRowCheckable(rowIndex: number): boolean {
|
|
604
|
+
* // All rows in the body are checkable
|
|
605
|
+
* if (this.areaIdent !== 'body') return false;
|
|
606
|
+
*
|
|
607
|
+
* // Except for special rows
|
|
608
|
+
* const row = this.getRowByIndex(rowIndex);
|
|
609
|
+
* return row && !row.locked;
|
|
610
|
+
* }
|
|
611
|
+
*/
|
|
37
612
|
isRowCheckable(_rowIndex: number): boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Returns the checked state of the row at the specified index.
|
|
615
|
+
* The base implementation returns undefined (not checked) and should be overridden by
|
|
616
|
+
* subclasses that support row selection.
|
|
617
|
+
*
|
|
618
|
+
* @param {number} _rowIndex - The index of the row
|
|
619
|
+
* @returns {CheckedType | undefined} The checked state of the row (true, false, or 'indeterminate'),
|
|
620
|
+
* or undefined if the row is not checkable
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* // Override in a subclass to implement row checked state
|
|
624
|
+
* isRowChecked(rowIndex: number): CheckedType | undefined {
|
|
625
|
+
* if (!this.rowSelectionModel) return undefined;
|
|
626
|
+
*
|
|
627
|
+
* const row = this.getRowByIndex(rowIndex);
|
|
628
|
+
* return this.rowSelectionModel.isRowChecked(row);
|
|
629
|
+
* }
|
|
630
|
+
*/
|
|
38
631
|
isRowChecked(_rowIndex: number): CheckedType | undefined;
|
|
632
|
+
/**
|
|
633
|
+
* Determines whether the cell at the specified row and column indices is selectable.
|
|
634
|
+
* If true, the user can select the cell.
|
|
635
|
+
* The base implementation returns false (not selectable) and should be overridden by
|
|
636
|
+
* subclasses that support cell selection.
|
|
637
|
+
*
|
|
638
|
+
* @param {number} _rowIndex - The index of the row
|
|
639
|
+
* @param {number} _columnIndex - The index of the column
|
|
640
|
+
* @returns {boolean} True if the cell is selectable, false otherwise
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* // Override in a subclass to implement cell selectability
|
|
644
|
+
* isSelectable(rowIndex: number, columnIndex: number): boolean {
|
|
645
|
+
* // All cells in the body are selectable
|
|
646
|
+
* return this.areaIdent === 'body';
|
|
647
|
+
* }
|
|
648
|
+
*/
|
|
39
649
|
isSelectable(_rowIndex: number, _columnIndex: number): boolean;
|
|
650
|
+
/**
|
|
651
|
+
* Sets the checked state of the row at the specified index.
|
|
652
|
+
* The base implementation does nothing and should be overridden by
|
|
653
|
+
* subclasses that support row selection.
|
|
654
|
+
*
|
|
655
|
+
* @param {number} _rowIndex - The index of the row
|
|
656
|
+
* @param {boolean} _checked - The new checked state
|
|
657
|
+
* @returns {void}
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* // Override in a subclass to implement row checking
|
|
661
|
+
* setRowChecked(rowIndex: number, checked: boolean): void {
|
|
662
|
+
* if (!this.rowSelectionModel) return;
|
|
663
|
+
*
|
|
664
|
+
* const row = this.getRowByIndex(rowIndex);
|
|
665
|
+
* if (row) {
|
|
666
|
+
* this.rowSelectionModel.checkRow(row, checked);
|
|
667
|
+
* }
|
|
668
|
+
* }
|
|
669
|
+
*/
|
|
40
670
|
setRowChecked(_rowIndex: number, _checked: boolean): void;
|
|
671
|
+
/**
|
|
672
|
+
* Sets the value of a cell at the specified row and column indices.
|
|
673
|
+
* This method is called when a cell is edited by the user or programmatically.
|
|
674
|
+
* The base implementation returns false (value not set) and should be overridden by
|
|
675
|
+
* subclasses that support cell editing.
|
|
676
|
+
*
|
|
677
|
+
* @param {number} _rowIndex - The index of the row containing the cell
|
|
678
|
+
* @param {number} _columnIndex - The index of the column containing the cell
|
|
679
|
+
* @param {any} _value - The new value to set
|
|
680
|
+
* @returns {boolean} - True if the value was successfully set, false otherwise
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* // Override in a subclass to implement cell value setting
|
|
684
|
+
* setValue(rowIndex: number, columnIndex: number, value: any): boolean {
|
|
685
|
+
* // Check if the cell is editable
|
|
686
|
+
* if (!this.isEditable(rowIndex, columnIndex)) return false;
|
|
687
|
+
*
|
|
688
|
+
* // For a 2D array model
|
|
689
|
+
* if (rowIndex >= 0 && rowIndex < this.data.length) {
|
|
690
|
+
* const row = this.data[rowIndex];
|
|
691
|
+
* if (columnIndex >= 0 && columnIndex < row.length) {
|
|
692
|
+
* row[columnIndex] = value;
|
|
693
|
+
* return true;
|
|
694
|
+
* }
|
|
695
|
+
* }
|
|
696
|
+
*
|
|
697
|
+
* return false;
|
|
698
|
+
* }
|
|
699
|
+
*/
|
|
41
700
|
setValue(_rowIndex: number, _columnIndex: number, _value: any): boolean;
|
|
42
701
|
}
|