[RadzenDataGrid] Filtering one List on RadzenDataGridColumn

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

The "Title" column in this demo is exactly OData filtering with in operator:

Here is how it looks the expression:

I know this page, the problem is the filter, do not convert the filter to odata string.
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

See filter property is empty, but in Result View I still have a FilterValue

AsODataEnumerable() is what tells the DataGrid to use OData filter expressions.

1 Like

Now the filters work using OData, my mistake, but the filter on the list is still wrong.

Client:

Server:

Using Postman:
The correct filtering is this:
$expand=N_Consulente_Commessa($expand=Commessa;$filter=CommessaId in (2,1))

Is there a way to tell him that it is a list and not a single property?

<RadzenDataGridColumn Sortable="false" Width="35%" Title="Commesse del consulente"
                                      TItem="ConsulenteDto" Type="typeof(IEnumerable<Consulente_CommessaDto>)" Property="@nameof(ConsulenteDto.N_Consulente_Commessa)" Context="consulente"
                                      FilterValue="SelectedCommesseFilter" FilterProperty="N_Consulente_Commessa.CommessaId" FilterOperator="FilterOperator.Contains" LogicalFilterOperator="LogicalFilterOperator.And"> Ecc..

Again, check the demo - everything you need is demonstrated there.