Class BOBDataCollectionBase<TItem, TComponent, TVariant>
- Namespace
- BlazOrbit.Components
- Assembly
- BlazOrbit.dll
Shared base for data-collection components (grid, cards) that own column registration, sorting, filtering, paging and selection state.
public abstract class BOBDataCollectionBase<TItem, TComponent, TVariant> : BOBVariantComponentBase<TComponent, TVariant>, IVariantComponent<TVariant>, IVariantComponent, IPureBuiltComponent, IBuiltComponent, IHasDensity, IHasSize, IHasShadow, IHasBorder, IHasBackgroundColor, IDataCollectionFamilyComponent where TComponent : BOBDataCollectionBase<TItem, TComponent, TVariant> where TVariant : Variant
Type Parameters
TItemRow item type.
TComponentConcrete derived component type (CRTP).
TVariantVariant type owned by the derived component.
- Inheritance
-
objectComponentBaseBOBVariantComponentBase<TComponent, TVariant>BOBDataCollectionBase<TItem, TComponent, TVariant>
- Implements
-
IVariantComponent<TVariant>
- Derived
- Inherited Members
Constructors
BOBDataCollectionBase()
protected BOBDataCollectionBase()
Fields
ColumnRegistry
protected readonly DataColumnRegistry<TItem> ColumnRegistry
Field Value
- DataColumnRegistry<TItem>
ColumnsBuilt
protected bool ColumnsBuilt
Field Value
- bool
FilteredItems
protected List<TItem> FilteredItems
Field Value
- List<TItem>
LiveRegionMessage
protected string? LiveRegionMessage
Field Value
- string
PaginationEnd
protected int PaginationEnd
Field Value
- int
PaginationStart
protected int PaginationStart
Field Value
- int
PreventRowKeyDown
protected bool PreventRowKeyDown
Field Value
- bool
ProcessedItems
protected List<TItem> ProcessedItems
Field Value
- List<TItem>
RegisteredColumns
protected List<DataColumnRegistration<TItem>> RegisteredColumns
Field Value
- List<DataColumnRegistration<TItem>>
State
protected readonly DataCollectionState<TItem> State
Field Value
- DataCollectionState<TItem>
TotalPages
protected int TotalPages
Field Value
- int
VisibleColumns
protected List<DataColumnRegistration<TItem>> VisibleColumns
Field Value
- List<DataColumnRegistration<TItem>>
Properties
BackgroundColor
Background color of the container. Accepts any valid CSS color value, PaletteColor or BOBColor.
[Parameter]
public string? BackgroundColor { get; set; }
Property Value
- string
Border
Border style applied to the container.
[Parameter]
public BorderStyle? Border { get; set; }
Property Value
BulkActions
Bulk actions rendered in the toolbar when at least one row is selected. Pair with SelectionMode = Multiple to expose mass-edit / delete / export workflows.
[Parameter]
public IReadOnlyList<DataCollectionBulkAction<TItem>>? BulkActions { get; set; }
Property Value
- IReadOnlyList<DataCollectionBulkAction<TItem>>
Columns
Column definitions rendered inside the data collection.
[Parameter]
public RenderFragment? Columns { get; set; }
Property Value
- RenderFragment
CustomFilter
Custom predicate used to filter items. Receives the item and the search text.
[Parameter]
public Func<TItem, string, bool>? CustomFilter { get; set; }
Property Value
- Func<TItem, string, bool>
DefaultSortColumn
Name of the column to sort by on initial render.
[Parameter]
public string? DefaultSortColumn { get; set; }
Property Value
- string
DefaultSortDirection
Initial sort direction. Defaults to Ascending.
[Parameter]
public SortDirection DefaultSortDirection { get; set; }
Property Value
Density
Vertical density (gap) of rows.
[Parameter]
public BOBDensity Density { get; set; }
Property Value
DraggingColumnHeader
Header currently being dragged for reorder, or null when idle.
protected string? DraggingColumnHeader { get; }
Property Value
- string
EmptyActionTemplate
Optional CTA template rendered alongside the empty state — pair with EmptyContent for "Create first record" buttons without rewriting the entire empty layout.
[Parameter]
public RenderFragment? EmptyActionTemplate { get; set; }
Property Value
- RenderFragment
EmptyContent
Custom template rendered when there are no items to display.
[Parameter]
public RenderFragment? EmptyContent { get; set; }
Property Value
- RenderFragment
EnableVirtualization
When true, only visible rows are rendered (improves performance for large lists).
[Parameter]
public bool EnableVirtualization { get; set; }
Property Value
- bool
Error
Error message. When non-empty (and Loading is off) the data area renders ErrorContent or a default error state instead of the rows.
[Parameter]
public string? Error { get; set; }
Property Value
- string
ErrorContent
Optional error template rendered in place of the data when Error is non-empty. Useful for surfacing remote-load failures without leaving an empty grid.
[Parameter]
public RenderFragment? ErrorContent { get; set; }
Property Value
- RenderFragment
FilterPlaceholder
Placeholder text for the filter search box.
[Parameter]
public string FilterPlaceholder { get; set; }
Property Value
- string
Filterable
When true, a search box filters the displayed items.
[Parameter]
public bool Filterable { get; set; }
Property Value
- bool
Height
Fixed height of the container. Required for virtualization and fixed header.
[Parameter]
public string? Height { get; set; }
Property Value
- string
Hoverable
When true (default), rows highlight on hover.
[Parameter]
public bool Hoverable { get; set; }
Property Value
- bool
IsInteractiveRow
protected bool IsInteractiveRow { get; }
Property Value
- bool
IsResizing
true while the user holds the resize handle on a column. Drives rendering of the full-grid drag overlay that captures pointermove / pointerup.
protected bool IsResizing { get; }
Property Value
- bool
ItemPattern
Alternating row style pattern (e.g. zebra striping).
[Parameter]
public RowStylePattern? ItemPattern { get; set; }
Property Value
Items
Data items to display.
[Parameter]
public IEnumerable<TItem>? Items { get; set; }
Property Value
- IEnumerable<TItem>
Loading
When true, the loading template is shown.
[Parameter]
public bool Loading { get; set; }
Property Value
- bool
LoadingContent
[Parameter]
public RenderFragment? LoadingContent { get; set; }
Property Value
- RenderFragment
LoadingMode
Visual mode used while Loading is on. Default Spinner — switch to Skeleton for animated row placeholders.
[Parameter]
public LoadingMode LoadingMode { get; set; }
Property Value
OnFilter
Raised when the filter text changes.
[Parameter]
public EventCallback<DataCollectionFilterEventArgs> OnFilter { get; set; }
Property Value
- EventCallback<DataCollectionFilterEventArgs>
OnPageChange
Raised when the current page changes.
[Parameter]
public EventCallback<DataCollectionPageChangeEventArgs> OnPageChange { get; set; }
Property Value
- EventCallback<DataCollectionPageChangeEventArgs>
OnRowClick
Raised when a row is clicked and SelectionMode is not active.
[Parameter]
public EventCallback<TItem> OnRowClick { get; set; }
Property Value
- EventCallback<TItem>
OnSort
Raised when the sort column or direction changes.
[Parameter]
public EventCallback<DataCollectionSortEventArgs> OnSort { get; set; }
Property Value
- EventCallback<DataCollectionSortEventArgs>
PageSize
Number of items per page. When null, pagination is disabled.
[Parameter]
public int? PageSize { get; set; }
Property Value
- int?
PageSizeOptions
Available page sizes shown in the page-size selector.
[Parameter]
public int[] PageSizeOptions { get; set; }
Property Value
- int[]
PersistenceKey
Optional storage key for the registered IDataCollectionStatePersistence. When set, the persistable slice of State (filter / sort / page / column order / column filters) is loaded on first render and saved after every state mutation. Default null = no persistence (the registered service is only consulted when this is non-empty).
[Parameter]
public string? PersistenceKey { get; set; }
Property Value
- string
Reorderable
When true, headers receive tabindex="0" + an
Alt+ArrowLeft / Alt+ArrowRight keyboard shortcut that shifts the
focused column toward the start or end of the row. Default false
for backwards-compat. Drag-based reorder is a separate slice (I1.S4 follow-up).
[Parameter]
public bool Reorderable { get; set; }
Property Value
- bool
Resizable
When true, columns whose Resizable parameter is on render
a drag handle on their trailing edge so the user can resize them via pointer
events. The drag clamps to each column's MinWidth / MaxWidth and
writes the new width to ColumnWidths;
the value participates in the persistence round-trip.
[Parameter]
public bool Resizable { get; set; }
Property Value
- bool
RowActions
Per-row action buttons rendered in a sticky-right action column (grid) or as an icon strip on each card. Clicks on action buttons stop propagation, so the row click only fires for non-action targets.
[Parameter]
public IReadOnlyList<DataCollectionRowAction<TItem>>? RowActions { get; set; }
Property Value
- IReadOnlyList<DataCollectionRowAction<TItem>>
RowDetailTemplate
Optional master-detail template. When non-null, every row gets a chevron toggle that expands a sub-row containing the rendered fragment. Useful for showing related data (order lines, audit trail) without navigation.
With EnableVirtualization the variable row height
breaks scroll-position math; pin a fixed ItemSize on
<Virtualize> when expansion is on.
[Parameter]
public RenderFragment<TItem>? RowDetailTemplate { get; set; }
Property Value
- RenderFragment<TItem>
SelectedItems
Currently selected items. Use with two-way binding.
[Parameter]
public HashSet<TItem>? SelectedItems { get; set; }
Property Value
- HashSet<TItem>
SelectedItemsChanged
Raised when the selection changes.
[Parameter]
public EventCallback<HashSet<TItem>> SelectedItemsChanged { get; set; }
Property Value
- EventCallback<HashSet<TItem>>
SelectionMode
Row selection mode.
[Parameter]
public SelectionMode SelectionMode { get; set; }
Property Value
Shadow
Shadow style applied to the container.
[Parameter]
public ShadowStyle? Shadow { get; set; }
Property Value
ShowColumnFilters
When true, render a per-column text filter input below the
header label for every BOBDataColumn<TItem> with
Filterable=true. Per-column filters AND-combine with the toolbar
Filterable search box. Default false for
backwards-compat.
[Parameter]
public bool ShowColumnFilters { get; set; }
Property Value
- bool
ShowPageSizeSelector
When true, a dropdown lets the user change the page size.
[Parameter]
public bool ShowPageSizeSelector { get; set; }
Property Value
- bool
Size
Visual size of the data collection.
[Parameter]
public BOBSize Size { get; set; }
Property Value
SortAppendBehavior
Sort Append Behavior for multi-column sorting. Defaults to Always. Values are None, Always, CtrlKey, ShiftKey, CtrlOrShiftKey.
[Parameter]
public SortAppendBehavior SortAppendBehavior { get; set; }
Property Value
Sortable
When true, column headers are clickable for sorting.
[Parameter]
public bool Sortable { get; set; }
Property Value
- bool
UsePerItemPatternStyles
protected bool UsePerItemPatternStyles { get; }
Property Value
- bool
Methods
ApplyFilter(IEnumerable<TItem>)
protected IEnumerable<TItem> ApplyFilter(IEnumerable<TItem> items)
Parameters
itemsIEnumerable<TItem>
Returns
- IEnumerable<TItem>
ApplyPagination(IEnumerable<TItem>)
protected IEnumerable<TItem> ApplyPagination(IEnumerable<TItem> items)
Parameters
itemsIEnumerable<TItem>
Returns
- IEnumerable<TItem>
ApplySort(IEnumerable<TItem>)
protected IEnumerable<TItem> ApplySort(IEnumerable<TItem> items)
Parameters
itemsIEnumerable<TItem>
Returns
- IEnumerable<TItem>
BuildComponentCssVariables(Dictionary<string, string>)
Contributes additional CSS custom properties to the inline style attribute. Keys
that collide with framework-owned --bob-inline-* variables will be overwritten.
public virtual void BuildComponentCssVariables(Dictionary<string, string> cssVariables)
Parameters
cssVariablesDictionary<string, string>
BuildComponentDataAttributes(Dictionary<string, object>)
Contributes additional data- attributes to the root element. Keys that collide
with framework-owned data-bob- attributes will be overwritten.
public virtual void BuildComponentDataAttributes(Dictionary<string, object> dataAttributes)
Parameters
dataAttributesDictionary<string, object>
CalculatePaginationInfo()
protected void CalculatePaginationInfo()
ChangePage(int)
protected Task ChangePage(int page)
Parameters
pageint
Returns
- Task
ClearFilter()
protected void ClearFilter()
ClearFilterClicked()
protected Task ClearFilterClicked()
Returns
- Task
ClearSelection()
protected Task ClearSelection()
Returns
- Task
ClearSelectionClicked()
protected Task ClearSelectionClicked()
Returns
- Task
EndColumnResize(PointerEventArgs)
Pointerup / pointercancel handler that ends the drag. Triggers a persistence save so the resized width survives across reloads when PersistenceKey is configured.
protected void EndColumnResize(PointerEventArgs e)
Parameters
ePointerEventArgs
Filter(string)
Applies a free-text filter and resets pagination to page 1.
public void Filter(string filterText)
Parameters
filterTextstring
FormatValue(object?, string?)
protected static string FormatValue(object? value, string? format)
Parameters
valueobjectformatstring
Returns
- string
GetAlignClass(ColumnAlign, string)
protected static string GetAlignClass(ColumnAlign align, string prefix)
Parameters
alignColumnAlignprefixstring
Returns
- string
GetAriaSort(DataColumnRegistration<TItem>)
protected string? GetAriaSort(DataColumnRegistration<TItem> col)
Parameters
colDataColumnRegistration<TItem>
Returns
- string
GetItemPatternStyle(int)
protected string? GetItemPatternStyle(int index)
Parameters
indexint
Returns
- string
GetOperatorsFor(ColumnFilterMode)
Returns the operator labels relevant to the column's ColumnFilterMode.
Drives the operator <select> options rendered next to the filter input.
protected static IEnumerable<ColumnFilterOperator> GetOperatorsFor(ColumnFilterMode mode)
Parameters
modeColumnFilterMode
Returns
- IEnumerable<ColumnFilterOperator>
GetSelectedItems()
Returns the set of currently selected items.
public IReadOnlySet<TItem> GetSelectedItems()
Returns
- IReadOnlySet<TItem>
GetVisiblePages()
protected IEnumerable<int> GetVisiblePages()
Returns
- IEnumerable<int>
GoToPage(int)
Navigates to the given 1-based page index. Out-of-range values are ignored.
public void GoToPage(int page)
Parameters
pageint
HandleColumnFilterInput(string, ChangeEventArgs)
Handler wired to the per-column filter input rendered in the data grid header when ShowColumnFilters is on. Updates ColumnFilters, resets pagination, and re-runs the filter pipeline.
protected Task HandleColumnFilterInput(string columnName, ChangeEventArgs e)
Parameters
columnNamestringeChangeEventArgs
Returns
- Task
HandleColumnFilterOperator(string, ChangeEventArgs)
Handler wired to the per-column operator <select> rendered in the
header next to the filter input. Updates the operator on the existing entry and
re-runs the pipeline; no-op when the column has no active text yet.
protected void HandleColumnFilterOperator(string columnName, ChangeEventArgs e)
Parameters
columnNamestringeChangeEventArgs
HandleFilterChange(ChangeEventArgs)
protected Task HandleFilterChange(ChangeEventArgs e)
Parameters
eChangeEventArgs
Returns
- Task
HandleFilterInputChange(string?)
protected Task HandleFilterInputChange(string? value)
Parameters
valuestring
Returns
- Task
HandleHeaderDragEnd(DragEventArgs)
Dragend handler clears the in-flight drag when the user releases outside any header.
protected void HandleHeaderDragEnd(DragEventArgs e)
Parameters
eDragEventArgs
HandleHeaderDragOver(string, DragEventArgs)
HTML5 dragover handler. Returning preventDefault via the matching
@ondragover:preventDefault attribute is what makes a target eligible for
drop; this handler is a no-op data hook so the grid can highlight the target.
protected void HandleHeaderDragOver(string columnName, DragEventArgs e)
Parameters
columnNamestringeDragEventArgs
HandleHeaderDragStart(string, DragEventArgs)
HTML5 dragstart handler for a reorder-enabled column header. Captures the source column so the matching drop handler knows which header to move. No-op when Reorderable is off so the gesture is opt-in.
protected void HandleHeaderDragStart(string columnName, DragEventArgs e)
Parameters
columnNamestringeDragEventArgs
HandleHeaderDrop(string, DragEventArgs)
Drop handler that translates the drag pair (source / target headers) into a MoveColumn(string, int, IEnumerable<string>) call by computing the index delta between the two columns in the current visible order.
protected void HandleHeaderDrop(string targetHeader, DragEventArgs e)
Parameters
targetHeaderstringeDragEventArgs
HandleHeaderKeyDown(string, KeyboardEventArgs)
Header keydown handler invoked when Reorderable is on.
Alt+ArrowLeft shifts the column one position toward the start, Alt+ArrowRight
toward the end. Other keys fall through so existing keyboard handling (sort cycling
via Enter) keeps working.
protected void HandleHeaderKeyDown(string columnName, KeyboardEventArgs e)
Parameters
columnNamestringeKeyboardEventArgs
HandlePageSizeChange(ChangeEventArgs)
protected Task HandlePageSizeChange(ChangeEventArgs e)
Parameters
eChangeEventArgs
Returns
- Task
HandlePageSizeSelectChange(string?)
protected Task HandlePageSizeSelectChange(string? value)
Parameters
valuestring
Returns
- Task
HandleRowClick(TItem)
protected Task HandleRowClick(TItem item)
Parameters
itemTItem
Returns
- Task
HandleRowKeyDown(KeyboardEventArgs, TItem)
protected Task HandleRowKeyDown(KeyboardEventArgs e, TItem item)
Parameters
eKeyboardEventArgsitemTItem
Returns
- Task
HandleSelectAll(ChangeEventArgs)
protected Task HandleSelectAll(ChangeEventArgs e)
Parameters
eChangeEventArgs
Returns
- Task
HandleSelectRow(TItem)
protected Task HandleSelectRow(TItem item)
Parameters
itemTItem
Returns
- Task
HandleSort(DataColumnRegistration<TItem>)
protected Task HandleSort(DataColumnRegistration<TItem> column)
Parameters
columnDataColumnRegistration<TItem>
Returns
- Task
HandleSort(DataColumnRegistration<TItem>, bool)
Toggle the sort state for the given column. append
= true stacks the sort instead of replacing it
(Shift+Click on the header). The notification fires with the new
primary sort.
protected Task HandleSort(DataColumnRegistration<TItem> column, bool append)
Parameters
columnDataColumnRegistration<TItem>appendbool
Returns
- Task
HandleSortClick(DataColumnRegistration<TItem>, MouseEventArgs)
Wrapper invoked from sort buttons that exposes the click args so
shiftKey can drive multi-column sort. Falls back to the
single-column toggle when Shift is not pressed.
protected Task HandleSortClick(DataColumnRegistration<TItem> column, MouseEventArgs e)
Parameters
columnDataColumnRegistration<TItem>eMouseEventArgs
Returns
- Task
HandleSortSelectChange(string?)
protected Task HandleSortSelectChange(string? value)
Parameters
valuestring
Returns
- Task
IsAllSelected()
protected bool IsAllSelected()
Returns
- bool
NotifySelectionChanged()
protected Task NotifySelectionChanged()
Returns
- Task
OnAfterRender(bool)
Method invoked after each time the component has rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any Microsoft.AspNetCore.Components.ElementReference fields will be populated by the time this runs.
This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.
protected override void OnAfterRender(bool firstRender)
Parameters
firstRenderboolSet to
trueif this is the first time Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(bool) has been invoked on this component instance; otherwisefalse.
Remarks
The Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(bool) and Microsoft.AspNetCore.Components.ComponentBase.OnAfterRenderAsync(bool) lifecycle methods
are useful for performing interop, or interacting with values received from @ref.
Use the firstRender parameter to ensure that initialization work is only performed
once.
OnInitialized()
Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.
protected override void OnInitialized()
OnParametersSet()
Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.
protected override void OnParametersSet()
OnResizePointerMove(PointerEventArgs)
Pointermove handler bound to the drag overlay; updates the column width on every frame the user moves the cursor while the resize handle is held.
protected void OnResizePointerMove(PointerEventArgs e)
Parameters
ePointerEventArgs
PersistState()
Fires the persistence pipeline. Wired into every state mutation handler — filter / sort / pagination / reorder / column filter — so the next reload restores the user's view. No-op when PersistenceKey is unset.
protected void PersistState()
ProcessData()
protected void ProcessData()
SortBy(string, SortDirection)
Sorts the collection by the given column header in the requested direction.
public void SortBy(string columnName, SortDirection direction)
Parameters
columnNamestringdirectionSortDirection
StartColumnResize(DataColumnRegistration<TItem>, PointerEventArgs)
Pointerdown handler for the per-column resize handle. Seeds the drag state with the column's current effective width (state override > parameter > default 120).
protected void StartColumnResize(DataColumnRegistration<TItem> col, PointerEventArgs e)
Parameters
colDataColumnRegistration<TItem>ePointerEventArgs
ToggleSortDirectionClicked()
protected Task ToggleSortDirectionClicked()
Returns
- Task
UpdateLiveRegionMessage()
protected void UpdateLiveRegionMessage()