Skip to content

Commit

Permalink
DataGrid advanced numeric filter second value fixed
Browse files Browse the repository at this point in the history
Fix #1817
  • Loading branch information
enchev committed Nov 29, 2024
1 parent a59a02a commit 11f9e5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Radzen.Blazor/RadzenDataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ internal RenderFragment DrawNumericFilter(RadzenDataGridColumn<TItem> column, bo
builder.AddAttribute(2, "ShowUpDown", column.ShowUpDownForNumericFilter());
builder.AddAttribute(3, "Style", "width:100%");
builder.AddAttribute(4, "InputAttributes", new Dictionary<string,object>(){ { "aria-label", column.Title + $"{(!isFirst ? " second " : " ")}filter value " + (isFirst ? column.GetFilterValue() : column.GetSecondFilterValue()) } });
builder.AddAttribute(5, "id", getFilterInputId(column));
builder.AddAttribute(5, "id", getFilterInputId(column) + (isFirst ? "f" : "s"));
Action<object> action;
if (force)
Expand Down
12 changes: 9 additions & 3 deletions Radzen.Blazor/RadzenDataGridHeaderCell.razor
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,16 @@ else
{
if (PropertyAccess.IsNumeric(Column.FilterPropertyType) && !(PropertyAccess.IsEnum(Column.FilterPropertyType) || PropertyAccess.IsNullableEnum(Column.FilterPropertyType)))
{
var inputValue = await Grid.GetJSRuntime().InvokeAsync<string>("Radzen.getNumericValue", Grid.getFilterInputId(Column));
if (!object.Equals($"{Column.GetFilterValue()}", inputValue))
var firstInputValue = await Grid.GetJSRuntime().InvokeAsync<string>("Radzen.getNumericValue", Grid.getFilterInputId(Column) + "f");
if (!object.Equals($"{Column.GetFilterValue()}", firstInputValue))
{
Column.SetFilterValue(!string.IsNullOrEmpty(inputValue) ? Convert.ChangeType(inputValue, Column.FilterPropertyType) : null);
Column.SetFilterValue(!string.IsNullOrEmpty(firstInputValue) ? Convert.ChangeType(firstInputValue, Column.FilterPropertyType) : null);
}

var secondInputValue = await Grid.GetJSRuntime().InvokeAsync<string>("Radzen.getNumericValue", Grid.getFilterInputId(Column) + "s");
if (!object.Equals($"{Column.GetSecondFilterValue()}", secondInputValue))
{
Column.SetFilterValue(!string.IsNullOrEmpty(secondInputValue) ? Convert.ChangeType(secondInputValue, Column.FilterPropertyType) : null, false);
}
}

Expand Down

0 comments on commit 11f9e5c

Please sign in to comment.