DataFilter OData error when FilterTemplate is bound directly to FilterValue #986

Open
opened 2026-01-29 17:47:21 +00:00 by claunia · 0 comments
Owner

Originally created by @parkrrr on GitHub (Sep 14, 2023).

Describe the bug
If you bind a FilterTemplate component directly to context.FilterValue it may not produce a valid OData filter string when all elements are selected.

In the DataFilter OData example, the DropDown component is bound to a specific selectedTitles list. This was not desirable to me because it prevents you from using the same filter twice in a query, as each filter is bound to the same list. I decided to try binding directly to context.FilterValue instead and had success:

<FilterTemplate>
    <RadzenDropDown @bind-Value=@context.FilterValue Style="width:100%;" SelectAllText="Select All" Data="@(titles)" AllowClear="true" Multiple="true" />
</FilterTemplate>

However, if the user clicks Select All and applies the filter, the resulting OData filter is invalid. If the user manually selects each title, the error does not occur.

Example repo: https://github.com/parkrrr/data-filter-error

To Reproduce
To reproduce In this repository example:

  1. Add a Employee Title filter and select all four titles individually
  2. Click Apply Filter and observe that the component functions correctly
  3. Clear the filter, then re-select all titles using the Select All check box
  4. Click Apply Filter and an error should occur

Expected behavior
The expected behavior is that the string values in the OData filter are surrounded in quotes:
Employee/Title in ('Sales Representative','Vice President, Sales','Sales Manager','Inside Sales Coordinator')

However the filter string that gets returned is not:
Employee/Title in (Sales Representative,Vice President, Sales,Sales Manager,Inside Sales Coordinator)

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version: 116.0.5845.188
Originally created by @parkrrr on GitHub (Sep 14, 2023). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** If you bind a FilterTemplate component directly to `context.FilterValue` it may not produce a valid OData filter string when all elements are selected. In the [DataFilter OData example](https://blazor.radzen.com/datafilter-odata), the DropDown component is bound to a specific `selectedTitles` list. This was not desirable to me because it prevents you from using the same filter twice in a query, as each filter is bound to the same list. I decided to try binding directly to `context.FilterValue` instead and had success: ``` <FilterTemplate> <RadzenDropDown @bind-Value=@context.FilterValue Style="width:100%;" SelectAllText="Select All" Data="@(titles)" AllowClear="true" Multiple="true" /> </FilterTemplate> ``` However, if the user clicks **Select All** and applies the filter, the resulting OData filter is invalid. If the user manually selects each title, the error does not occur. Example repo: https://github.com/parkrrr/data-filter-error **To Reproduce** To reproduce In this repository example: 1. Add a **Employee Title** filter and select all four titles individually 2. Click **Apply Filter** and observe that the component functions correctly 3. Clear the filter, then re-select all titles using the **Select All** check box 4. Click **Apply Filter** and an error should occur **Expected behavior** The expected behavior is that the string values in the OData filter are surrounded in quotes: `Employee/Title in ('Sales Representative','Vice President, Sales','Sales Manager','Inside Sales Coordinator')` However the filter string that gets returned is not: `Employee/Title in (Sales Representative,Vice President, Sales,Sales Manager,Inside Sales Coordinator)` **Desktop (please complete the following information):** - OS: Windows - Browser: Chrome - Version: 116.0.5845.188
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#986