[PR #908] Add ability to customize OData string by column #2390

Closed
opened 2026-01-29 18:18:36 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/radzenhq/radzen-blazor/pull/908

State: closed
Merged: Yes


This allows users of the data grid to override OData expression generation for niche cases that aren't ready for the main repo. For my use-case, I have a column representing a List, and I want to search for any one of the values in it. With this PR, I can inherit RadzenDataGridColumn to fit my specific needs:

    public class CustomProofOfConceptRadzenDataGridColumn<TItem> : RadzenDataGridColumn<TItem>
    {
        protected override string GetColumnODataFilter(object filterValue, FilterOperator filterOperator)
        {
            var property = GetFilterProperty().Replace('.', '/');

            if (FilterPropertyType == typeof(List<string>) && filterValue is string)
            {
                return $"{property}/any(x: x eq '{filterValue}')";
            }

            return base.GetColumnODataFilter(filterValue, filterOperator);
        }
    }

An idea for future improvement is to, instead of using a virtual method for the customization, add a Func<object, FilterOperator, string> parameter, though I didn't feel comfortable adding such an option without getting the opinions of the maintainers first.

**Original Pull Request:** https://github.com/radzenhq/radzen-blazor/pull/908 **State:** closed **Merged:** Yes --- This allows users of the data grid to override OData expression generation for niche cases that aren't ready for the main repo. For my use-case, I have a column representing a List<string>, and I want to search for any one of the values in it. With this PR, I can inherit RadzenDataGridColumn to fit my specific needs: ``` public class CustomProofOfConceptRadzenDataGridColumn<TItem> : RadzenDataGridColumn<TItem> { protected override string GetColumnODataFilter(object filterValue, FilterOperator filterOperator) { var property = GetFilterProperty().Replace('.', '/'); if (FilterPropertyType == typeof(List<string>) && filterValue is string) { return $"{property}/any(x: x eq '{filterValue}')"; } return base.GetColumnODataFilter(filterValue, filterOperator); } } ``` An idea for future improvement is to, instead of using a virtual method for the customization, add a Func<object, FilterOperator, string> parameter, though I didn't feel comfortable adding such an option without getting the opinions of the maintainers first.
claunia added the pull-request label 2026-01-29 18:18:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#2390