Extras
DataGrid
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.
Columns & styling
Resizing, reordering, hiding, freezing and grouping columns, column spans, borders, stripes and row numbers, row and cell styles with tooltips, text wrapping and row height, and the empty and loading states.
Column layout
MinWidth (60 px) and MaxWidth (none) bound the resize in pixels; Shift with an arrow key takes bigger steps. Resizable and Reorderable on a column override the grid's, and a disabled grid does neither. AutoFitColumnAsync and AutoFitAllColumnsAsync fit from code, measuring the rendered content and header; MoveColumnAsync moves a column to a 0-based position.
The column chooser shows and hides columns, and moves them only while the grid is Reorderable. A column's Visible (default
true) sets whether it starts shown. A hidden column is left out of the exports
and the clipboard too.
Frozen pins to the start edge (the left in LTR, the right in RTL) and FrozenEnd to the end edge; a column with both is Frozen. In the Excel export, the frozen columns become frozen panes. A Group header spans runs of consecutive columns with the same name, so a column moved away from the others of its group no longer sits under it.
Column spanning
The function returns how many columns the cell covers, counted in the visible columns from its own;
null, 1 or anything below 1 covers just its own, and a span past the last column stops there. The covered
cells are not rendered, so their values do not show in that row - render what the row needs in the spanning cell's
Template, as here. Keyboard navigation steps over a span as one cell, and the Excel export writes it as a merged
region. Hiding or reordering columns changes what a span covers. While any column has a ColSpan,
VirtualizeColumns is not applied.
Borders, striping & row numbers
Bordered draws the outer border and the lines between columns; the lines between rows are drawn either way. Striped shades every other row and Hoverable highlights the row under the pointer. Their colors are the --bit-DataGrid-border-color, -stripe-background and -hover-background CSS variables (see Style & Class). Row numbers keep counting across pages, a virtualized window and infinite-scroll batches, and are left out of the clipboard as well as the exports.
Row & cell styling
Each selector is called per row and returns
null for nothing extra. RowClass is added after the
grid's own row classes and the Classes.Row / SelectedRow ones, and RowStyle after the row's layout
style. On a column, CellClass is a fixed class for every cell, CellClassSelector adds one per row after it,
and CellStyleSelector's style is applied last, so it wins over the grid's own cell styles - prefer
color and font-* to background, which would hide the selected and hovered
states. HeaderClass styles the column's header cell.
The classes land on elements the grid renders, so CSS isolation reaches them only through
::deep from a
plain element of your page, which is why the grid sits in a div here (see the stylesheet tab). The Stock
column names its TItem because it is handed a method group, from which the compiler cannot infer the row
type. The tooltips only go on cells that show the column's own value - a Template draws its own.
Text wrapping & row height
Without wrapping, a value too long for its column is cut off with an ellipsis; ShowCellTooltips (in Row & cell styling) keeps it readable instead. WrapText="false" keeps a column on one line while the grid wraps, as the ID, Price and Stock columns do here, and WrapText="true" wraps one column of a grid that does not. Both heights are in pixels and are minimums: a row still grows to fit wrapped text. While Virtualize is on, RowHeightSelector is ignored as well and RowHeight is every row's exact height.
Empty & loading states
Without an EmptyTemplate the message is Strings.EmptyText ("No items found") when there are no rows, and Strings.NoMatchesText ("No results found") when a filter or the search is on - the rows exist but none match. Both texts default to BitStrings.Current, read each time they are shown. An EmptyTemplate is shown in both cases, so give it wording that fits a fruitless search as well, or leave it out.
Loading hides the rows for as long as it is set rather than dimming them. A server grid (OnRead) does not need it: it marks itself busy while it reads and shows the loading row only while it has no rows yet, keeping the rows on screen while the next ones load - set Loading yourself to hide them then too. The header and toolbar stay in place. Classes.Empty / Classes.Loading (and their Styles) style the two messages.
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.