Files
radzen-blazor/Radzen.Blazor/RadzenPickList.razor
2026-07-03 08:34:20 +03:00

63 lines
5.4 KiB
Plaintext

@inherits RadzenComponent
@using System.Collections
@using Microsoft.AspNetCore.Components.Forms
@typeparam TItem
@if (Visible)
{
<div @ref="@Element" @attributes="Attributes" class="@GetCssClass()" style="@GetStyle()" id="@GetId()">
<RadzenStack class="rz-picklist-wrapper" Orientation="@Orientation">
<RadzenStack class="rz-picklist-source-wrapper">
@if (ShowHeader && SourceHeader != null)
{
<div id="@(GetId() + "-source-header")">
@SourceHeader
</div>
}
<CascadingValue Value="@((EditContext?)null)" IsFixed=true>
<RadzenListBox @ref=sourceListBox Value=@selectedSourceItems ValueChanged="@(EventCallback.Factory.Create<object>(this, OnSelectedSourceItemsChanged))" Data="@source" Multiple="@Multiple" @bind-SearchText=@sourceSearchText
FilterAsYouType=true FilterCaseSensitivity=FilterCaseSensitivity.CaseInsensitive
TextProperty="@TextProperty" ValueProperty="@ValueProperty" DisabledProperty="@DisabledProperty" AllowFiltering=@AllowFiltering ItemRender="@OnSourceItemRender"
Template=@SourceListBoxTemplate Placeholder="@(SourcePlaceholder ?? Placeholder)" SelectAllText="@SelectAllText" AllowSelectAll="@AllowSelectAll"
Disabled=@(Disabled || Source == null || (Source != null && !Source.Any()))
EmptyText="@(SourceEmptyText ?? EmptyText)" EmptyTemplate="@(SourceEmptyTemplate ?? EmptyTemplate)"
AllowVirtualization="@AllowVirtualization"
aria-label="@(ShowHeader && SourceHeader != null ? null : SourceAriaLabel)"
aria-labelledby="@(ShowHeader && SourceHeader != null ? GetId() + "-source-header" : null)"
/>
</CascadingValue>
</RadzenStack>
<RadzenStack Orientation="@(Orientation == Orientation.Vertical ? Orientation.Horizontal : Orientation.Vertical)" JustifyContent="@ButtonJustifyContent" Gap="@ButtonGap" class="rz-picklist-buttons">
<RadzenButton Icon="@SelectedSourceToTargetIcon" title="@SelectedSourceToTargetTitle" aria-label="@SelectedSourceToTargetTitle" Click="@SelectedSourceToTarget" Disabled=@(Disabled || selectedSourceItems == null || (Multiple && (selectedSourceItems as IEnumerable)?.Cast<object>().Any() != true))
ButtonStyle="@ButtonStyle" Size="@ButtonSize" Variant="@ButtonVariant" Shade="@ButtonShade" />
<RadzenButton Icon="@SelectedTargetToSourceIcon" title="@SelectedTargetToSourceTitle" aria-label="@SelectedTargetToSourceTitle" Click="@SelectedTargetToSource" Disabled=@(Disabled || selectedTargetItems == null || (Multiple && (selectedTargetItems as IEnumerable)?.Cast<object>().Any() != true))
ButtonStyle="@ButtonStyle" Size="@ButtonSize" Variant="@ButtonVariant" Shade="@ButtonShade"/>
<RadzenButton Icon="@SourceToTargetIcon" title="@SourceToTargetTitle" aria-label="@SourceToTargetTitle" Click="@SourceToTarget" Disabled=@(Disabled || source == null || (source != null && !source.Any()))
ButtonStyle="@ButtonStyle" Size="@ButtonSize" Variant="@ButtonVariant" Shade="@ButtonShade" Visible=@(AllowMoveAll && AllowMoveAllSourceToTarget) />
<RadzenButton Icon="@TargetToSourceIcon" title="@TargetToSourceTitle" aria-label="@TargetToSourceTitle" Click="@TargetToSource" Disabled=@(Disabled || target == null|| (target != null && !target.Any()))
ButtonStyle="@ButtonStyle" Size="@ButtonSize" Variant="@ButtonVariant" Shade="@ButtonShade" Visible=@(AllowMoveAll && AllowMoveAllTargetToSource)/>
</RadzenStack>
<RadzenStack class="rz-picklist-target-wrapper">
@if (ShowHeader && TargetHeader != null)
{
<div id="@(GetId() + "-target-header")">
@TargetHeader
</div>
}
<CascadingValue Value="@((EditContext?)null)" IsFixed=true>
<RadzenListBox @ref=targetListBox Value=@selectedTargetItems ValueChanged="@(EventCallback.Factory.Create<object>(this, OnSelectedTargetItemsChanged))" Data="@target" Multiple="@Multiple" @bind-SearchText=@targetSearchText
FilterAsYouType=true FilterCaseSensitivity=FilterCaseSensitivity.CaseInsensitive
TextProperty="@TextProperty" ValueProperty="@ValueProperty" DisabledProperty="@DisabledProperty" AllowFiltering=@AllowFiltering ItemRender="@OnTargetItemRender"
Template=@TargetListBoxTemplate Placeholder="@(TargetPlaceholder ?? Placeholder)" SelectAllText="@SelectAllText" AllowSelectAll="@AllowSelectAll"
Disabled=@(Disabled || Target == null|| (Target != null && !Target.Any()))
EmptyText="@(TargetEmptyText ?? EmptyText)" EmptyTemplate="@(TargetEmptyTemplate ?? EmptyTemplate)"
AllowVirtualization="@AllowVirtualization"
aria-label="@(ShowHeader && TargetHeader != null ? null : TargetAriaLabel)"
aria-labelledby="@(ShowHeader && TargetHeader != null ? GetId() + "-target-header" : null)"
/>
</CascadingValue>
</RadzenStack>
</RadzenStack>
</div>
}