@vii7/div-table-widget 1.0.1 → 1.1.0
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 +108 -1
- package/dist/divtable.min.js +1 -1
- package/package.json +1 -1
- package/src/div-table.css +76 -0
- package/src/div-table.js +1586 -423
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ A modern, flexible table widget built with CSS Grid and Flexbox instead of HTML
|
|
|
10
10
|
- **Advanced Query Language**: Monaco Editor integration with intelligent autocomplete and syntax highlighting
|
|
11
11
|
- **Virtual Scrolling**: Efficiently handle large datasets with pagination support
|
|
12
12
|
- **Fixed (Frozen) Columns**: Keep important columns visible while scrolling horizontally
|
|
13
|
+
- **Summary Rows**: Aggregate calculations (sum, avg, count, min, max) with header and group summaries
|
|
13
14
|
- **Auto-Fetch**: Automated pagination with play/pause/resume controls
|
|
14
15
|
- **Grouping & Sorting**: Multi-level grouping with 4-state sorting (alphabetical asc/desc, count asc/desc)
|
|
15
16
|
- **Selection Management**: Single and multi-row selection with checkbox support
|
|
@@ -22,7 +23,7 @@ A modern, flexible table widget built with CSS Grid and Flexbox instead of HTML
|
|
|
22
23
|
## Installation
|
|
23
24
|
|
|
24
25
|
```bash
|
|
25
|
-
npm install
|
|
26
|
+
npm install @vii7/div-table-widget monaco-editor
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
## Quick Start
|
|
@@ -109,6 +110,8 @@ const divTable = new DivTable(monaco, {
|
|
|
109
110
|
| `group` | String | `null` | Field to group by initially (applies grouping on load) |
|
|
110
111
|
| `sort` | Object | `null` | Initial sort: `{ field: string, direction: 'asc'|'desc' }` |
|
|
111
112
|
| `fixedColumns` | Number | `0` | Number of columns to freeze on the left side when scrolling horizontally |
|
|
113
|
+
| `showHeaderSummary` | Boolean | `false` | Show summary row at top with aggregates for all visible data |
|
|
114
|
+
| `showGroupSummary` | Boolean | `false` | Show summary row after each group with group aggregates |
|
|
112
115
|
|
|
113
116
|
### Virtual Scrolling Options
|
|
114
117
|
|
|
@@ -269,6 +272,25 @@ divTable.stopAutoFetch();
|
|
|
269
272
|
|
|
270
273
|
Keep the first N columns fixed (frozen) on the left side while scrolling horizontally:
|
|
271
274
|
|
|
275
|
+
**Visual Layout:**
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
┌──────────────────────────┬─────────────────────────────────────────────────┐
|
|
279
|
+
│ FIXED SECTION │ SCROLLABLE SECTION ──────────► │
|
|
280
|
+
│ (stays in place) │ (scrolls horizontally) │
|
|
281
|
+
├──────────────────────────┼─────────────────────────────────────────────────┤
|
|
282
|
+
│ ☐ │ ID │ Name │ Email │ Department │ Status │ ...│
|
|
283
|
+
├──────────────────────────┼─────────────────────────────────────────────────┤
|
|
284
|
+
│ ☐ │ 1 │ John Doe │ john@mail.com │ Engineering │ Active │ │
|
|
285
|
+
│ ☐ │ 2 │ Jane Smith │ jane@mail.com │ Marketing │ Active │ │
|
|
286
|
+
│ ☐ │ 3 │ Bob Wilson │ bob@mail.com │ Sales │ Inactive│ │
|
|
287
|
+
└──────────────────────────┴─────────────────────────────────────────────────┘
|
|
288
|
+
▲ ▲
|
|
289
|
+
│ │
|
|
290
|
+
Columns 1-2 Columns 3+ scroll
|
|
291
|
+
stay fixed left/right
|
|
292
|
+
```
|
|
293
|
+
|
|
272
294
|
```javascript
|
|
273
295
|
const divTable = new DivTable(monaco, {
|
|
274
296
|
tableWidgetElement: document.getElementById('table-container'),
|
|
@@ -292,6 +314,90 @@ const divTable = new DivTable(monaco, {
|
|
|
292
314
|
- Checkbox column (if enabled) is always part of the fixed section
|
|
293
315
|
- Works with composite columns - each composite group counts as one column
|
|
294
316
|
|
|
317
|
+
### Summary Rows (Aggregates)
|
|
318
|
+
|
|
319
|
+
Display aggregate calculations in summary rows at the header level (grand totals) or after each group (subtotals):
|
|
320
|
+
|
|
321
|
+
**Visual Layout:**
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
325
|
+
│ ☐ │ Name │ Department │ Age │ Salary │
|
|
326
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
327
|
+
│ │ │ │ 32 avg │ $385,000 ◄── Header Summary (Grand Total)
|
|
328
|
+
├═════════════════════════════════════════════════════════════════════════┤
|
|
329
|
+
│ ▼ │ Engineering (3) │ ◄── Group Header
|
|
330
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
331
|
+
│ ☐ │ Alice Chen │ Engineering │ 28 │ $95,000 │
|
|
332
|
+
│ ☐ │ Bob Smith │ Engineering │ 35 │ $120,000 │
|
|
333
|
+
│ ☐ │ Carol Davis │ Engineering │ 42 │ $110,000 │
|
|
334
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
335
|
+
│ │ │ │ 35 avg │ $325,000 ◄── Group Summary (Subtotal)
|
|
336
|
+
├═════════════════════════════════════════════════════════════════════════┤
|
|
337
|
+
│ ▶ │ Marketing (2) (collapsed) │ ◄── Collapsed Group
|
|
338
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
339
|
+
│ │ │ │ 27 avg │ $60,000 ◄── Summary visible even when collapsed
|
|
340
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
```javascript
|
|
344
|
+
const divTable = new DivTable(monaco, {
|
|
345
|
+
tableWidgetElement: document.getElementById('table-container'),
|
|
346
|
+
columns: [
|
|
347
|
+
{ field: 'id', label: 'ID', primaryKey: true },
|
|
348
|
+
{ field: 'name', label: 'Name' },
|
|
349
|
+
{ field: 'department', label: 'Department', groupable: true },
|
|
350
|
+
{
|
|
351
|
+
field: 'salary',
|
|
352
|
+
label: 'Salary',
|
|
353
|
+
align: 'right', // Right-align numeric values
|
|
354
|
+
aggregate: 'sum', // Calculate sum for this column
|
|
355
|
+
aggregateRender: (value) => `$${value.toLocaleString()}` // Format aggregate value
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
field: 'age',
|
|
359
|
+
label: 'Age',
|
|
360
|
+
aggregate: 'avg', // Calculate average
|
|
361
|
+
aggregateRender: (value) => `${value.toFixed(1)} avg`
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
data: myData,
|
|
365
|
+
group: 'department',
|
|
366
|
+
showHeaderSummary: true, // Show grand total row at top
|
|
367
|
+
showGroupSummary: true // Show subtotal after each group
|
|
368
|
+
});
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Aggregate Types:**
|
|
372
|
+
|
|
373
|
+
| Type | Description |
|
|
374
|
+
|------|-------------|
|
|
375
|
+
| `sum` | Sum of all numeric values |
|
|
376
|
+
| `avg` | Average of all numeric values |
|
|
377
|
+
| `count` | Count of non-null values |
|
|
378
|
+
| `min` | Minimum value |
|
|
379
|
+
| `max` | Maximum value |
|
|
380
|
+
|
|
381
|
+
**Column Configuration for Aggregates:**
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
{
|
|
385
|
+
field: 'amount',
|
|
386
|
+
label: 'Amount',
|
|
387
|
+
align: 'right', // Align cell content (applies to both data and summary cells)
|
|
388
|
+
aggregate: 'sum', // Aggregate type: 'sum', 'avg', 'count', 'min', 'max'
|
|
389
|
+
aggregateRender: (value) => `$${value.toFixed(2)}` // Custom formatting for aggregate value
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Features:**
|
|
394
|
+
|
|
395
|
+
- Summary rows remain visible even when groups are collapsed
|
|
396
|
+
- Aggregates automatically update when data changes or filters are applied
|
|
397
|
+
- Selection-aware: When rows are selected, aggregates reflect only selected data
|
|
398
|
+
- Works with fixed columns layout
|
|
399
|
+
- Supports custom formatting via `aggregateRender` function
|
|
400
|
+
|
|
295
401
|
## Column Configuration
|
|
296
402
|
|
|
297
403
|
### Basic Column
|
|
@@ -303,6 +409,7 @@ const divTable = new DivTable(monaco, {
|
|
|
303
409
|
primaryKey: false, // Is this the primary key? (required for one column)
|
|
304
410
|
hidden: false, // Hide column (default: false)
|
|
305
411
|
groupable: true, // Allow grouping by this column (default: true)
|
|
412
|
+
align: 'left', // Text alignment: 'left', 'center', 'right' (default: 'left')
|
|
306
413
|
render: (value, item) => `<strong>${value}</strong>` // Custom render function
|
|
307
414
|
}
|
|
308
415
|
```
|