Class TwTableRows<TItem>
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
The typed rows of a TwTable. Place it in the table's TableBody and give it the rows, and the table pages them (EnablePagination) or renders only the ones in view (EnableVirtualization).
public class TwTableRows<TItem> : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IAsyncDisposable
Type Parameters
TItemThe type of the rows.
- Inheritance
-
TwTableRows<TItem>
- Implements
- Inherited Members
Remarks
Without either option every row renders, so it also works as a plain typed loop. The rows can come from Items, or be loaded a page or a scrolled window at a time from ItemsProvider.
Constructors
TwTableRows()
public TwTableRows()
Properties
ChildContent
Gets or sets the markup for one row, a <tr>, given the row's item.
[Parameter]
public RenderFragment<TItem>? ChildContent { get; set; }
Property Value
- RenderFragment<TItem>
CurrentItems
Gets the rows currently on screen: the current page, or every row when the table is not paged. While virtualized, the rows ItemsProvider last returned.
public IReadOnlyList<TItem> CurrentItems { get; }
Property Value
- IReadOnlyList<TItem>
EmptyContent
Gets or sets what to render when there are no rows, such as a row with a message.
[Parameter]
public RenderFragment? EmptyContent { get; set; }
Property Value
Items
Gets or sets the rows. Leave it unset when ItemsProvider loads them instead.
[Parameter]
public IEnumerable<TItem>? Items { get; set; }
Property Value
- IEnumerable<TItem>
ItemsLoaded
Raised each time ItemsProvider returns rows, with the rows and the total count.
[Parameter]
public EventCallback<TwTableRowsResult<TItem>> ItemsLoaded { get; set; }
Property Value
- EventCallback<TwTableRowsResult<TItem>>
ItemsProvider
Gets or sets a function that loads rows on demand, such as from a database or an API, in place of Items. It is asked for one page at a time with EnablePagination, for each scrolled window with EnableVirtualization, and for every row otherwise.
[Parameter]
public TwTableRowsProvider<TItem>? ItemsProvider { get; set; }
Property Value
- TwTableRowsProvider<TItem>
LoadingContent
Gets or sets what to render while ItemsProvider loads rows that are not on screen yet.
[Parameter]
public RenderFragment? LoadingContent { get; set; }
Property Value
PageTemplate
Gets or sets the markup for every row on the current page at once, in place of a template per row. Use it
inside RowGroups to split a page into several <tbody> elements. Not used
with EnableVirtualization.
[Parameter]
public RenderFragment<TwTableRowsPage<TItem>>? PageTemplate { get; set; }
Property Value
- RenderFragment<TwTableRowsPage<TItem>>
RowTemplate
Gets or sets the markup for one row, a <tr>, given the row's item, its place among all the rows,
and the aria-rowindex to put on it. Use it in place of ChildContent with
EnableVirtualization, so screen readers know where each rendered row sits.
[Parameter]
public RenderFragment<TwTableRow<TItem>>? RowTemplate { get; set; }
Property Value
- RenderFragment<TwTableRow<TItem>>
TotalCount
Gets how many rows there are in total, across every page.
public int TotalCount { get; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
DisposeAsync()
Stops any load still running and leaves the table.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that completes once the load is cancelled.
OnAfterRenderAsync(bool)
Method invoked after each time the component has been rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any 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.
Note that the component does not automatically re-render after the completion of any returned Task, because that would cause an infinite render loop.
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRenderboolSet to
trueif this is the first time OnAfterRender(bool) has been invoked on this component instance; otherwisefalse.
Returns
Remarks
The OnAfterRender(bool) and 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()
RefreshDataAsync()
Asks ItemsProvider for the rows on screen again, such as after the data changed or the sort or filter the provider applies changed. Without a provider, shows Items again.
public Task RefreshDataAsync()
Returns
- Task
A task that completes once the rows are loaded.