[PR #1408] [CLOSED] feat: DataGridSettings with CustomFilterExpression #2720

Open
opened 2026-01-29 18:20:10 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/radzenhq/radzen-blazor/pull/1408
Author: @marekm294
Created: 3/4/2024
Status: Closed

Base: masterHead: feature/DataGridSettingsWithCustomFilterExpression


📝 Commits (2)

  • 3790c16 feat: DataGridSettings with CustomFilterExpression
  • d02014c fix: condition improved

📊 Changes

2 files changed (+131 additions, -106 deletions)

View changed files

📝 Radzen.Blazor/Common.cs (+6 -1)
📝 Radzen.Blazor/RadzenDataGrid.razor.cs (+125 -105)

📄 Description

CustomFilterExpression wasn't included in DataGridSettings. Added in this PR,

PR seems to be big but there are almost no changes.
DataGridSettings,Columns have default value Enumerable.Empty<>() which can save us checking if columns == null (not expected anyway).

var gridColumn = ColumnsCollection.Where(c => !string.IsNullOrEmpty(column.Property) && c.Property == column.Property).FirstOrDefault() ??
                                ColumnsCollection.Where(c => !string.IsNullOrEmpty(column.UniqueID) && c.UniqueID == column.UniqueID).FirstOrDefault();

was extracted to method

        private RadzenDataGridColumn<TItem> GetColumnByPropertyAndUniqueIdOrDefault(DataGridColumnSettings dataGridColumnSettings)
        {
            return ColumnsCollection
                .Where(c => !string.IsNullOrEmpty(dataGridColumnSettings.Property) && c.Property == dataGridColumnSettings.Property)
                .FirstOrDefault() ?? ColumnsCollection
                    .Where(c => !string.IsNullOrEmpty(dataGridColumnSettings.UniqueID) && c.UniqueID == dataGridColumnSettings.UniqueID)
                    .FirstOrDefault();
        }

and used
var gridColumn = GetColumnByPropertyAndUniqueIdOrDefault(column);
because there was the same code duplicated.

if (SettingsChanged.HasDelegate)
{
    // content of the method
}

changed to

if (SettingsChanged.HasDelegate == false)
{
   return;
}

// content of the method

to make code more readable

the same with

if (gridColumn == null)
{
    continue;
}

which is reason why the PR looks so big

Only signicificant change is adding this:

if (gridColumn.GetCustomFilterExpression() != column.CustomFilterExpression &&
    !string.IsNullOrEmpty(column.CustomFilterExpression) &&
    gridColumn.FilterOperator == FilterOperator.Custom)
{
    gridColumn.SetCustomFilterExpression(column.CustomFilterExpression);
    shouldUpdateState = true;
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/radzenhq/radzen-blazor/pull/1408 **Author:** [@marekm294](https://github.com/marekm294) **Created:** 3/4/2024 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feature/DataGridSettingsWithCustomFilterExpression` --- ### 📝 Commits (2) - [`3790c16`](https://github.com/radzenhq/radzen-blazor/commit/3790c1656d58e8b17dd3ce3a2fd12f2f86a1c45e) feat: DataGridSettings with CustomFilterExpression - [`d02014c`](https://github.com/radzenhq/radzen-blazor/commit/d02014c42ea7c44eaceba1be24c1d07b4ce906d3) fix: condition improved ### 📊 Changes **2 files changed** (+131 additions, -106 deletions) <details> <summary>View changed files</summary> 📝 `Radzen.Blazor/Common.cs` (+6 -1) 📝 `Radzen.Blazor/RadzenDataGrid.razor.cs` (+125 -105) </details> ### 📄 Description CustomFilterExpression wasn't included in DataGridSettings. Added in this PR, PR seems to be big but there are almost no changes. DataGridSettings,Columns have default value Enumerable.Empty<>() which can save us checking if columns == null (not expected anyway). ``` var gridColumn = ColumnsCollection.Where(c => !string.IsNullOrEmpty(column.Property) && c.Property == column.Property).FirstOrDefault() ?? ColumnsCollection.Where(c => !string.IsNullOrEmpty(column.UniqueID) && c.UniqueID == column.UniqueID).FirstOrDefault(); ``` was extracted to method ``` private RadzenDataGridColumn<TItem> GetColumnByPropertyAndUniqueIdOrDefault(DataGridColumnSettings dataGridColumnSettings) { return ColumnsCollection .Where(c => !string.IsNullOrEmpty(dataGridColumnSettings.Property) && c.Property == dataGridColumnSettings.Property) .FirstOrDefault() ?? ColumnsCollection .Where(c => !string.IsNullOrEmpty(dataGridColumnSettings.UniqueID) && c.UniqueID == dataGridColumnSettings.UniqueID) .FirstOrDefault(); } ``` and used `var gridColumn = GetColumnByPropertyAndUniqueIdOrDefault(column);` because there was the same code duplicated. ``` if (SettingsChanged.HasDelegate) { // content of the method } ``` changed to ``` if (SettingsChanged.HasDelegate == false) { return; } // content of the method ``` to make code more readable the same with ``` if (gridColumn == null) { continue; } ``` which is reason why the PR looks so big Only signicificant change is adding this: ``` if (gridColumn.GetCustomFilterExpression() != column.CustomFilterExpression && !string.IsNullOrEmpty(column.CustomFilterExpression) && gridColumn.FilterOperator == FilterOperator.Custom) { gridColumn.SetCustomFilterExpression(column.CustomFilterExpression); shouldUpdateState = true; } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 18:20:10 +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#2720