Hi everyone,
I’m trying to apply a filter on a certain column that contains a list type property (it would be a many to many relationship).
As you can see from the code I created a custom filter that filters this column based on all the results
I’m trying to get back from the LoadDataArgs class the correct filter that is a list that contains only certain selected id.
And once you have the set of filters convert them with the class ODataExtensions with the GetODataUri method to return the odata string to be passed to the endpoint.
The problem is to write the correct filter based on the column (A list of multiple entities filtered by Id)
Then return to the LoadDataArgs filter the correct selection of all entities that have that particular Id as a relation
The other filters work, but obviously the filter on the list is wrong and I don’t understand why, can you understand where I’m wrong?
Code Razor:
<RadzenDataGridColumn Sortable="false" Width="25%" TItem="ConsulenteDto" Property="N_Consulente_Commessa" Context="consulente" Title="Commesse del consulente"
FilterProperty="@nameof(Consulente_CommessaDto.CommessaId)" FilterValue="commesseFilterSelectedColumn" FilterOperator="FilterOperator.Contains" LogicalFilterOperator="LogicalFilterOperator.And">
<FilterTemplate>
<RadzenDropDownDataGrid @ref="gridFilterCommesse" AllowFiltering="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowClear="true" @bind-Value=@commesseFilterSelectedColumn
Multiple="true" Placeholder="Applica filtro commesse" Data=@commesseFilterColumn TextProperty="Name" ValueProperty="Id">
<Columns>
<RadzenDropDownDataGridColumn Sortable="false">
<HeaderTemplate>
<RadzenCheckBox TriState="false" TValue="bool" Value="@(commesseFilterColumn.Any(c => commesseFilterSelectedColumn != null && commesseFilterSelectedColumn.Contains(c.Id)))"
Change="@(args => commesseFilterSelectedColumn = args ? gridFilterCommesse.View.Cast<CommessaDto>().Select(c => c.Id) : commesseFilterSelectedColumn = Enumerable.Empty<int>())" />
</HeaderTemplate>
<Template Context="comm">
<RadzenCheckBox TriState="false" Value="@(commesseFilterSelectedColumn != null && commesseFilterSelectedColumn.Contains(((CommessaDto)comm).Id))"
TValue="bool" Change=@(args => {
}) />
</Template>
</RadzenDropDownDataGridColumn>
<RadzenDropDownDataGridColumn Property="Id" Title="Commessa Id" />
<RadzenDropDownDataGridColumn Property="Name" Title="Nome" />
</Columns>
</RadzenDropDownDataGrid>
</FilterTemplate>
</RadzenDataGridColumn>
Code Cs:
public RadzenDropDownDataGrid<IEnumerable<int>> gridFilterCommesse { get; set; }
public IEnumerable<CommessaDto> commesseFilterColumn { get; set; } = Enumerable.Empty<CommessaDto>();
public IEnumerable<int> commesseFilterSelectedColumn { get; set; } = Enumerable.Empty<int>();
public async Task LoadData(LoadDataArgs args = null)
{
Response<PagingResponse<ConsulenteDto>> response = null;
response = await consulenteService.GetAll(CurrentPage, PageSize, args.Filter);
}
Thanks in advance,
Andrea