Ferose
April 11, 2025, 1:18pm
1
Hi, I want to add an option to show only selected rows or all rows in a grid with multi-select. Is their an easy way to do this (are the selected rows filterable in some way)?
So when I click my button I get this.
I can get it to work by filtering the datasource but can not undo it easly with out requerying data.
enchev
April 11, 2025, 1:25pm
2
Use the items provided by @bind-Value , check our selection demos for reference.
Ferose
April 11, 2025, 1:36pm
3
Hi
I am using bind value (see code below) and I can use the selected rows to filter Data, but it changes the Data source so I can not undo it. Or am I going about this the wrong way, is there a way to apply filter to grid using the Selected values?
<RadzenDataGrid @ref="wbsLevel1Grid" IsLoading=@isLoading Data="@wbsLevel1DataSource" TItem="WbsFilterDto" Width="150px" MinWidth="60px"
AllowSorting=@FormatSettings.AllowSorting AllowFiltering=@FormatSettings.AllowFiltering AllowPaging=@FormatSettings.AllowPaging
PageSize=@FormatSettings.PageSize PagerHorizontalAlign=@FormatSettings.FormPagerAlignment ShowPagingSummary=@FormatSettings.ShowPagingSummary PageSizeOptions=@FormatSettings.PageSizeOptions
GotoFirstPageOnSort="true" FilterMode=@FormatSettings.Filtermode FilterCaseSensitivity=@FormatSettings.filterCaseSensitivity GridLines=@FormatSettings.FormGridlines
AllowColumnResize=@FormatSettings.AllowColumnResize AllowColumnReorder=@FormatSettings.MultiPickAllowColumnReorder
Density=@FormatSettings.FormDensity
AllowRowSelectOnRowClick="true" SelectionMode="DataGridSelectionMode.Multiple" @bind-Value=@selectedWbsLevel1s>
<HeaderTemplate>
<RadzenRow AlignItems="AlignItems.End">
<RadzenText>
@GetLevel1Message()
</RadzenText>
<RadzenButton Icon="check_circle" Text="Selected" Click="@ShowSelected" title="Show Selected Only" Variant="Variant.Flat" Shade="Shade.Lighter" />
<RadzenButton Icon="set_meal" Text="All" Click="@ShowAll" title="Show All" Variant="Variant.Flat" Shade="Shade.Lighter" />
</RadzenRow>
@code {
IEnumerable<WbsFilterDto> wbsLevel1DataSource = [];
RadzenDataGrid<WbsFilterDto> wbsLevel1Grid;
IList<WbsFilterDto> selectedWbsLevel1s = [];
protected void ShowSelected()
{
wbsLevel1DataSource = wbsLevel1DataSource.Where(x => selectedWbsLevel1s.Select(x => x.Id).ToList().Contains(x.Id));
}