Skip to content

Extras

DataGrid

Bit.BlazorUI.ExtrasDataTableTreeGridTreeList

BitDataGrid displays an information-rich data table and gives people the tools to work through it: sorting, quick search and per-column filters, paging, grouping with aggregates, selection, inline editing, resizable/reorderable/frozen columns, master-detail and tree rows, keyboard cell navigation, row and column virtualization, and CSV/Excel export. Bind a list, an IQueryable executed at the source, or a callback for server-side paging or infinite scrolling. Use a data grid when information density is critical.

Editing, grouping & templates

Inline row and cell editing with validation, grouping with group and footer aggregates, cell, header and footer templates with custom sort keys, and master-detail rows.

Inline editing

Editable adds a command column and NewItemFactory an Add button. Editors follow each column's type, edits are buffered until saved, and Validate blocks an invalid value (clear a name, or enter a negative price). EditMode edits the whole row (Save/Cancel) or one cell at a time: Enter, F2 or a double-click opens it, and typing into a text or number cell opens it with what you type; Enter, Tab or leaving it saves; Esc cancels; Delete removes the focused row. A row double-click here calls BeginEdit via OnRowDoubleClick.

The grid edits the row object but never your list: the built-in editors write into a buffer, and only Save writes it to the row and raises OnRowSave - persist the change there. Cancel (or Esc) drops the buffer and raises OnRowCancel. OnRowCreate hands over the row NewItemFactory built as it opens for editing, and OnRowDelete the row to delete: the grid only deselects it, so remove it from Items yourself. One row is edited at a time, and while it is open, row clicks neither select nor expand anything.

A column is editable when the grid (or its own Editable) says so and it is bound to a property with a setter; Editable="false" keeps ID read-only here, and template-only columns are never edited. The editor follows DataType: a text box, a number box, a date picker, or a dropdown for booleans and enums. A value that cannot be converted shows Strings.InvalidValueError. Validate receives the row and the converted value and returns an error message, or null to accept it; while any column has an error, saving is refused and the message shows under its editor. A column's EditTemplate replaces the built-in editor with your own markup; it binds straight to the row rather than to the buffer, and Cancel restores the values the row had when the edit began.

Cell mode turns cell navigation on, and Tab saves and moves to the next editable cell. From code: BeginEdit / BeginEditAsync (a row, or a cell by column id), CommitEditAsync, CancelEditAsync, AddNewRowAsync and DeleteRowAsync; EditingItem and EditingColumnId tell what is open. A row type that is a struct cannot be edited, since the grid would only change a copy.


Actions
1
Vintage Gadget 212
Home
$171.75
131
2023-01-19
False
2
Eco Notebook 554
Clothing
$382.16
130
2019-07-18
True
3
Classic Gadget 181
Toys
$813.02
269
2023-03-12
False
4
Vintage Blender 267
Electronics
$310.12
291
2021-01-25
True
5
Vintage Jacket 234
Electronics
$55.50
390
2022-08-20
True
6
Smart Drone 229
Electronics
$603.51
257
2020-02-18
False
7
Eco Widget 428
Books
$72.97
359
2023-12-08
False
8
Pro Blender 549
Electronics
$825.55
6
2020-06-02
True
9
Deluxe Mug 514
Clothing
$615.44
22
2021-08-11
True
10
Mini Jacket 367
Grocery
$585.87
367
2018-10-04
False
1–10 of 25
Page 1 of 3

Double-click a row, or use its Edit button.

Grouping & aggregates

Groupable adds a ⊞ toggle to the headers; group by Category, then Supplier, for nested groups. Each group shows its columns' Aggregate, ShowFooter shows the grand totals, and AggregateBy computes a custom one. GroupsInitiallyCollapsed opens the groups closed; ExpandAllGroupsAsync / CollapseAllGroupsAsync flip them all.

Grouping works on in-memory lists only: it is not offered with OnRead, OnLoadMore, an IQueryable or a tree, and a column needs a bound property to be grouped by. A grouped grid shows every row, so the pager is set aside while it is grouped. Groupable on a column overrides the grid's. From code, GroupByAsync adds a level, UngroupAsync removes one and ClearGroupsAsync all of them; OnGroupChange reports the new grouping. Expand-all and collapse-all also hold for groups built later, after a regrouping or new data.

Aggregate picks a built-in function - Sum, Average (of the numeric values), Count (of the rows), Min or Max (of the non-null values) - and AggregateBy takes the group's (or the whole view's) rows and returns any value, winning over Aggregate. The result is formatted with AggregateFormat, or else the column's Format. The group header shows the aggregates beside its title and count; ShowFooter adds a footer row with the same aggregates over every row of the view, whatever the page.


1
Vintage Gadget 212
Home
Wayne Enterprises
$171.75
131
3.9
2
Eco Notebook 554
Clothing
Soylent
$382.16
130
3.1
3
Classic Gadget 181
Toys
Wonka Inc
$813.02
269
1.2
4
Vintage Blender 267
Electronics
Wayne Enterprises
$310.12
291
4.3
5
Vintage Jacket 234
Electronics
Wayne Enterprises
$55.50
390
3.5
6
Smart Drone 229
Electronics
Stark Industries
$603.51
257
1.2
7
Eco Widget 428
Books
Wayne Enterprises
$72.97
359
1.3
8
Pro Blender 549
Electronics
Acme Corp
$825.55
6
1.0
9
Deluxe Mug 514
Clothing
Wayne Enterprises
$615.44
22
2.5
10
Mini Jacket 367
Grocery
Initech
$585.87
367
1.1
11
Vintage Gadget 192
Home
Soylent
$334.92
388
1.6
12
Mini Mug 788
Toys
Acme Corp
$712.80
144
3.2
13
Classic Mug 124
Books
Acme Corp
$267.79
19
1.9
14
Compact Gadget 195
Clothing
Wayne Enterprises
$325.60
375
4.3
15
Deluxe Speaker 932
Sports
Initech
$281.65
272
3.5
16
Eco Widget 307
Grocery
Initech
$982.55
390
1.5
17
Mini Blender 740
Electronics
Wonka Inc
$597.20
195
4.5
18
Pro Blender 952
Sports
Stark Industries
$132.04
53
1.0
19
Classic Drone 459
Electronics
Soylent
$906.58
481
4.6
20
Mega Mug 839
Sports
Wonka Inc
$282.70
169
3.1
21
Mega Speaker 349
Books
Wonka Inc
$830.28
320
1.3
22
Modern Mug 947
Home
Stark Industries
$886.86
484
1.6
23
Mini Backpack 199
Sports
Wayne Enterprises
$349.39
260
3.9
24
Mini Speaker 940
Electronics
Initech
$60.13
107
2.3
25
Deluxe Lamp 430
Home
Initech
$760.77
331
5.0
26
Eco Mug 633
Toys
Initech
$388.23
478
1.3
27
Compact Camera 900
Electronics
Stark Industries
$300.37
290
1.1
28
Mega Mug 366
Grocery
Stark Industries
$749.69
15
2.4
29
Mini Jacket 409
Books
Acme Corp
$604.08
321
3.4
30
Premium Camera 361
Grocery
Globex
$352.80
0
3.3
31
Mega Gadget 949
Books
Initech
$654.24
99
3.6
32
Mega Lamp 485
Books
Stark Industries
$787.62
277
3.2
33
Compact Backpack 302
Clothing
Wayne Enterprises
$540.00
406
3.8
34
Pro Mug 551
Grocery
Umbrella
$45.94
206
2.7
35
Ultra Mug 514
Clothing
Wayne Enterprises
$484.40
357
2.7
36
Pro Camera 944
Home
Wayne Enterprises
$211.34
473
4.5
37
Mini Notebook 156
Electronics
Umbrella
$900.67
312
4.7
38
Premium Jacket 198
Electronics
Wayne Enterprises
$651.34
10
1.9
39
Classic Drone 215
Sports
Acme Corp
$290.56
272
1.2
40
Mini Sneaker 570
Sports
Wayne Enterprises
$897.23
338
4.6
41
Modern Camera 946
Sports
Globex
$661.07
44
4.2
42
Vintage Mug 824
Sports
Initech
$444.42
453
1.8
43
Mini Mug 925
Electronics
Wonka Inc
$843.33
173
4.4
44
Premium Camera 560
Grocery
Globex
$35.33
277
3.6
45
Vintage Gadget 237
Home
Wonka Inc
$383.48
282
4.9
46
Pro Drone 577
Electronics
Initech
$285.56
438
4.7
47
Eco Jacket 846
Grocery
Wonka Inc
$59.26
414
2.8
48
Smart Camera 226
Toys
Initech
$612.62
229
4.1
49
Classic Gadget 202
Electronics
Globex
$494.25
256
2.4
50
Mega Sneaker 417
Sports
Soylent
$955.45
169
2.1
51
Premium Gadget 932
Clothing
Wayne Enterprises
$741.93
301
2.9
52
Premium Lamp 283
Toys
Soylent
$943.60
49
2.2
53
Pro Mug 237
Toys
Initech
$264.98
237
3.1
54
Eco Lamp 139
Electronics
Wonka Inc
$175.86
112
1.9
55
Ultra Lamp 134
Grocery
Wayne Enterprises
$47.06
77
3.3
56
Ultra Blender 911
Grocery
Initech
$80.83
62
5.0
57
Ultra Gadget 323
Books
Stark Industries
$647.39
313
2.7
58
Deluxe Blender 420
Home
Acme Corp
$506.54
17
4.8
59
Deluxe Camera 513
Sports
Acme Corp
$234.18
305
3.3
60
Eco Mug 642
Electronics
Umbrella
$809.15
442
1.8
61
Vintage Lamp 246
Books
Acme Corp
$971.43
238
1.8
62
Eco Backpack 738
Electronics
Acme Corp
$366.59
112
3.8
63
Ultra Notebook 129
Home
Soylent
$488.57
483
4.9
64
Deluxe Widget 171
Books
Wayne Enterprises
$384.18
206
3.8
65
Classic Gadget 833
Electronics
Soylent
$866.59
268
1.8
66
Eco Backpack 963
Books
Acme Corp
$371.05
236
2.8
67
Mini Mug 765
Sports
Wonka Inc
$200.57
57
3.5
68
Mini Jacket 661
Books
Wonka Inc
$632.20
439
2.7
69
Modern Jacket 576
Electronics
Wonka Inc
$429.20
49
1.4
70
Compact Mug 696
Sports
Wayne Enterprises
$244.82
228
2.7
71
Compact Backpack 959
Sports
Umbrella
$57.23
410
1.5
72
Ultra Lamp 199
Toys
Acme Corp
$249.92
68
2.7
73
Ultra Backpack 762
Sports
Globex
$991.34
272
3.8
74
Pro Jacket 295
Sports
Soylent
$37.91
45
2.7
75
Compact Notebook 426
Clothing
Acme Corp
$869.12
262
4.5
76
Ultra Sneaker 789
Toys
Soylent
$743.04
101
4.7
77
Premium Notebook 878
Clothing
Globex
$39.85
338
1.9
78
Vintage Drone 655
Toys
Umbrella
$121.29
349
2.4
79
Mega Backpack 316
Sports
Wayne Enterprises
$138.33
341
3.4
80
Premium Speaker 971
Home
Globex
$496.89
335
2.8

Templates

Template, HeaderTemplate and FooterTemplate render any markup. A template-only column sorts by its SortBy key, and Comparer replaces the ordering itself - Stock sorts in-stock rows first.

A Template only changes how a cell looks: a bound column still sorts, filters, searches, groups and exports by its value, so Rating and Stock above keep all of that. FooterTemplate receives the column's BitDataGridAggregateResult (Value, FormattedValue, Type), so it renders only where the column has an Aggregate or AggregateBy and the footer is on. A template owns its markup, so the cell tooltips of ShowCellTooltips are not added to it.

A template-only column (no Property or Field, like Value) has no value of its own: give it a ColumnId, since its id is otherwise generated, and know that it is not filtered, grouped, searched or exported unless you give it an ExportValue (see Export). SortBy and Comparer run in memory only: an IQueryable sorts a bound column by its property and cannot sort a template-only one, and OnRead / OnLoadMore receive the column id to sort by - a template-only column takes part there with ServerSortable and a ColumnId. SortBy on a bound column replaces its value as the sort key.

Vintage Gadget 212
Home
★★★★★
$171.75
131 in stock
$22,499
Eco Notebook 554
Clothing
★★★★★
$382.16
130 in stock
$49,681
Classic Gadget 181
Toys
★★★★★
$813.02
269 in stock
$218,702
Vintage Blender 267
Electronics
★★★★★
$310.12
291 in stock
$90,245
Vintage Jacket 234
Electronics
★★★★★
$55.50
390 in stock
$21,645
Smart Drone 229
Electronics
★★★★★
$603.51
257 in stock
$155,102
Eco Widget 428
Books
★★★★★
$72.97
359 in stock
$26,196
Pro Blender 549
Electronics
★★★★★
$825.55
6 in stock
$4,953
Deluxe Mug 514
Clothing
★★★★★
$615.44
22 in stock
$13,540
Mini Jacket 367
Grocery
★★★★★
$585.87
367 in stock
$215,014
Vintage Gadget 192
Home
★★★★★
$334.92
388 in stock
$129,949
Mini Mug 788
Toys
★★★★★
$712.80
144 in stock
$102,643
Classic Mug 124
Books
★★★★★
$267.79
19 in stock
$5,088
Compact Gadget 195
Clothing
★★★★★
$325.60
375 in stock
$122,100
Deluxe Speaker 932
Sports
★★★★★
$281.65
272 in stock
$76,609
Eco Widget 307
Grocery
★★★★★
$982.55
390 in stock
$383,195
Mini Blender 740
Electronics
★★★★★
$597.20
195 in stock
$116,454
Pro Blender 952
Sports
★★★★★
$132.04
53 in stock
$6,998
Classic Drone 459
Electronics
★★★★★
$906.58
481 in stock
$436,065
Mega Mug 839
Sports
★★★★★
$282.70
169 in stock
$47,776
Mega Speaker 349
Books
★★★★★
$830.28
320 in stock
$265,690
Modern Mug 947
Home
★★★★★
$886.86
484 in stock
$429,240
Mini Backpack 199
Sports
★★★★★
$349.39
260 in stock
$90,841
Mini Speaker 940
Electronics
★★★★★
$60.13
107 in stock
$6,434
Deluxe Lamp 430
Home
★★★★★
$760.77
331 in stock
$251,815
Eco Mug 633
Toys
★★★★★
$388.23
478 in stock
$185,574
Compact Camera 900
Electronics
★★★★★
$300.37
290 in stock
$87,107
Mega Mug 366
Grocery
★★★★★
$749.69
15 in stock
$11,245
Mini Jacket 409
Books
★★★★★
$604.08
321 in stock
$193,910
Premium Camera 361
Grocery
★★★★★
$352.80
Out of stock
$0

Detail rows

DetailTemplate renders anything under a row - here a nested grid. A row opens from its ▸ toggle, from a click on the row (ExpandDetailOnRowClick) or from code; ShowDetailToggle="false" hides the toggle column, ExpandedDetailItems is bindable and OnDetailToggle reports each change.

With ExpandDetailOnRowClick a click also selects the row in Single SelectionMode; clicks on the toggle, checkbox, reorder and command cells, and on a control inside a cell, open nothing. Several rows can be open at once. Binding ExpandedDetailItems puts the open rows in your hands - the grid then only reports changes through ExpandedDetailItemsChanged; leave it unset and drive the rows with ExpandDetailAsync, CollapseDetailAsync, ToggleDetailAsync, SetDetailExpandedAsync, ExpandAllDetailsAsync (the rows of the view - only the loaded ones with OnRead, an IQueryable or OnLoadMore) and CollapseAllDetailsAsync, and read them with IsDetailExpanded. OnDetailToggle reports a single row's toggle, with the row and whether it opened.

A detail row is as tall as its content, which Virtualize cannot measure: pair detail rows with paging rather than virtualization. A grid nested in a detail row is a grid of its own; give it an AriaLabel that says whose rows it shows.

Click a row, or its ▸ toggle, to open it.

Details

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.