Hi,
I want to load dat from server dynamically and I wan to use the filtering template on the server side.
How can I call the LoadData method with the selected element from RadzenDropDown, please?
Is this possible?
UPDATE
I have found your answer for this question.
Calling Reload() from your template should trigger LoadData()
Thank you.
UPDATE2
But how I can pass the filter property, value and filter operator to the LoadDataArgs?
It says the FilterValue and FilterOperator should not be set outside of its component and
x.FilterProperty is null.
<RadzenDataGridColumn TItem="ReportVM" Title="District" Property="District" FilterProperty="DistrictId">
<FilterTemplate>
<RadzenDropDown @bind-Value="@currentDistrict" TextProperty="Text" ValueProperty="Value" Style="width:100%" Data="@rdistrictList" Change=@(() => OnChange("DistrictId")) />
</FilterTemplate>
</RadzenDataGridColumn>
void OnChange(string filterPorperty)
{
var column = table.ColumnsCollection.FirstOrDefault(x => x.FilterProperty.Equals(filterPorperty));
if (column is not null)
{
column.FilterValue = currentDistrict.ValueInt;
column.FilterOperator = FilterOperator.Equals;
table.Reload();
}
}
SOLUTION
protected DropDownData currentDistrict= new DropDownData { ValueInt = 0, Text = "All" };
....
<RadzenDataGridColumn TItem="ReportVM" Title="District" Property="District" FilterProperty="DistrictId">
<FilterTemplate>
<RadzenDropDown @bind-Value="@currentDistrict" TextProperty="Text" ValueProperty="Value" Style="width:100%" Data="@rdistrictList" Change=@(() => OnChange("District")) />
</FilterTemplate>
</RadzenDataGridColumn>
....
void OnChange(string porperty)
{
var column = table.ColumnsCollection.Where(x => x.Property.Equals(porperty)).FirstOrDefault();
if (column is not null)
{
column.FilterValue = currentDistrict.ValueInt;
column.FilterOperator = FilterOperator.Equals;
if (currentDistrict.ValueInt == 0)
{
column.FilterOperator = FilterOperator.GreaterThan;
}
table.Reload();
}
}
protected async Task LoadDataAsync(LoadDataArgs args)
{
....
regionList = ....
regionList = regionList.Prepend(new DropDownData { ValueInt = 0, Text = "All" });
regionList = regionList.Prepend(currentDistrict);
....
}