Jhibbs
April 1, 2024, 4:53pm
1
i have looked up some examples and cannot find my exact issue. i want to have a default value (active) for the radzen dropdown, that filters on load.
here is my column:
<RadzenDataGridColumn TItem="ContractData" Property="ContractStatus" Title="Status" Width="75px" FilterValue="@FValueStatus" FilterOperator="FilterOperator.Contains" LogicalFilterOperator="LogicalFilterOperator.Or" Type="typeof(IEnumerable<string>)">
<FilterTemplate>
<RadzenDropDown @bind-Value=@FValueStatus Style="width:100%;"
Change=@OnSelectedFValueStatusChange Data="@(StatusValuesList)" AllowClear="true" Multiple="true"/>
</FilterTemplate>
</RadzenDataGridColumn>
and setups:
IEnumerable FValueStatus;
List StatusValuesList = new List { "Active", "Closed" };
but it seems there isnt a proper way to set defaults. i have looked at some examples where using the bind value will auto select it, but in this case changing bind value no longer allows filter.
Jhibbs
April 1, 2024, 6:40pm
3
after more issues of trial an error, i have something that is no longer erroring randomly.
My Column - which i swapped bind-value(dropdown) and filter property(column), and was playing with the change value:
<RadzenDataGridColumn TItem="ContractData" Property="ContractStatus" Title="Status" Width="75px" FilterValue="@defaultValuesList" FilterOperator="FilterOperator.Contains" LogicalFilterOperator="LogicalFilterOperator.Or" Type="typeof(IEnumerable<string>)">
<FilterTemplate>
<RadzenDropDown @bind-Value=@defaultValuesList Style="width:100%;"
Change=@OnSelectedFValueStatusChange Data="@(StatusValuesList)" AllowClear="true" Multiple="true" />
</FilterTemplate>
</RadzenDataGridColumn>
and added code:
IEnumerable<string> defaultValuesList = new List<string> { "Active" };
public void OnSelectedFValueStatusChange(object value)
{
if (defaultValuesList != null && !defaultValuesList.Any())
{
defaultValuesList = null;
}
}
in fact, looking closely, it looks like i just needed to initialize my original
IEnumerable FValueStatus;