Class TwPickList<TItem>
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Represents a dual list-box ("pick list") that moves items between a source and a target collection, with two-way binding on both lists plus optional up/down reordering within either one.
public class TwPickList<TItem> : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
Type Parameters
TItemThe type of items in both lists.
- Inheritance
-
TwPickList<TItem>
- Implements
- Inherited Members
Remarks
Selection is tracked internally by value equality (EqualityComparer<T>), the same
approach used by TwCheckboxGroup<TValue> - so items that compare equal are
selected/deselected together. SelectedSourceItems and SelectedTargetItems
only seed the initial selection (like Checked) rather than staying
fully controlled, since re-syncing from the parameter on every render would immediately overwrite a
click with a caller that isn't also echoing the corresponding Changed callback back in.
Constructors
TwPickList()
public TwPickList()
Properties
AllowReorder
Gets or sets whether each column shows up/down buttons for reordering its current selection.
[Parameter]
public bool AllowReorder { get; set; }
Property Value
Disabled
Gets or sets whether the whole component is disabled.
[Parameter]
public bool Disabled { get; set; }
Property Value
EmptyText
Gets or sets the text shown in place of a list that has no items.
[Parameter]
public string EmptyText { get; set; }
Property Value
SelectedSourceItems
Gets or sets the source list's initially selected items. Only read once, at first render - see the remarks on TwPickList<TItem>.
[Parameter]
public IEnumerable<TItem> SelectedSourceItems { get; set; }
Property Value
- IEnumerable<TItem>
SelectedSourceItemsChanged
Gets or sets the callback invoked whenever the source list's selection changes.
[Parameter]
public EventCallback<IEnumerable<TItem>> SelectedSourceItemsChanged { get; set; }
Property Value
- EventCallback<IEnumerable<TItem>>
SelectedTargetItems
Gets or sets the target list's initially selected items. Only read once, at first render - see the remarks on TwPickList<TItem>.
[Parameter]
public IEnumerable<TItem> SelectedTargetItems { get; set; }
Property Value
- IEnumerable<TItem>
SelectedTargetItemsChanged
Gets or sets the callback invoked whenever the target list's selection changes.
[Parameter]
public EventCallback<IEnumerable<TItem>> SelectedTargetItemsChanged { get; set; }
Property Value
- EventCallback<IEnumerable<TItem>>
ShowMoveAllButtons
Gets or sets whether the "move all" (double chevron) buttons are shown alongside the single-transfer chevron buttons.
[Parameter]
public bool ShowMoveAllButtons { get; set; }
Property Value
SourceItems
Gets or sets the items available in the source (left) list.
[Parameter]
public IEnumerable<TItem> SourceItems { get; set; }
Property Value
- IEnumerable<TItem>
SourceItemsChanged
Gets or sets the callback invoked when items move into or out of the source list, or are reordered within it.
[Parameter]
public EventCallback<IEnumerable<TItem>> SourceItemsChanged { get; set; }
Property Value
- EventCallback<IEnumerable<TItem>>
SourceLabel
Gets or sets the heading shown above the source list.
[Parameter]
public string SourceLabel { get; set; }
Property Value
TargetItems
Gets or sets the items in the target (right) list.
[Parameter]
public IEnumerable<TItem> TargetItems { get; set; }
Property Value
- IEnumerable<TItem>
TargetItemsChanged
Gets or sets the callback invoked when items move into or out of the target list, or are reordered within it.
[Parameter]
public EventCallback<IEnumerable<TItem>> TargetItemsChanged { get; set; }
Property Value
- EventCallback<IEnumerable<TItem>>
TargetLabel
Gets or sets the heading shown above the target list.
[Parameter]
public string TargetLabel { get; set; }
Property Value
TextField
Gets or sets the name of the property to display for each item.
[Parameter]
public string TextField { get; set; }
Property Value
Remarks
If null, empty, or not found on TItem, the item's ToString() is used.
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
OnParametersSet()
Invoked when the component's parameters have been set. Ensures that the component has a unique identifier by generating one if none is provided.
protected override void OnParametersSet()
Remarks
If the component's identifier is not set, a unique ID is generated based on the component's type name (with a 'Tw' prefix removed if present) and a GUID. This helps ensure that each component instance can be uniquely identified, which is useful for scenarios such as associating labels with form elements or targeting elements in client-side scripts.