Skip to content

Commit

Permalink
Fixed DataGrid CheckBoxList filtering with LoadData and In/NotIn oper…
Browse files Browse the repository at this point in the history
…ator
  • Loading branch information
enchev committed Dec 16, 2024
1 parent 1d1335f commit 261339c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Radzen.Blazor/QueryableExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public static string ToFilterString<T>(this IEnumerable<RadzenDataGridColumn<T>>
string baseType = column.FilterPropertyType.GetGenericArguments().Count() == 1
? column.FilterPropertyType.GetGenericArguments()[0].Name
: "";

if (column.Property != column.FilterProperty)
{
baseType = "";
}

var enumerableValueAsString = "new " + baseType + "[]{" + String.Join(",",
(enumerableValue.ElementType == typeof(string)
? enumerableValue.Cast<string>().Select(i => $@"""{i}""")
Expand Down Expand Up @@ -222,7 +228,16 @@ public static string ToFilterString<T>(this IEnumerable<RadzenDataGridColumn<T>>
}
else if (columnFilterOperator == FilterOperator.In || columnFilterOperator == FilterOperator.NotIn)
{
whereList.Add($@"({property}).{(columnFilterOperator == FilterOperator.NotIn ? "Except" : "Intersect")}({enumerableValueAsString}).Any()");
if (IsEnumerable(column.FilterPropertyType) && column.FilterPropertyType != typeof(string) &&
IsEnumerable(column.PropertyType) && column.PropertyType != typeof(string))
{
whereList.Add($@"{(columnFilterOperator == FilterOperator.NotIn ? "!" : "")}{property}.Any(i => i in {enumerableValueAsString})");
}
else if (IsEnumerable(column.FilterPropertyType) && column.FilterPropertyType != typeof(string) &&
column.Property != column.FilterProperty && !string.IsNullOrEmpty(column.FilterProperty))
{
whereList.Add($@"{(columnFilterOperator == FilterOperator.NotIn ? "!" : "")}{column.Property}.Any(i => i.{column.FilterProperty} in {enumerableValueAsString})");
}
}
}
else
Expand Down

0 comments on commit 261339c

Please sign in to comment.