Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RadzenDataFilter numeric input fixes #1843

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Radzen.Blazor/RadzenDataFilter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@if (Visible)
{
<div @ref="@Element" style="@Style" @attributes="Attributes" class="@GetCssClass()" id="@GetId()">
<RadzenSelectBar @bind-Value=LogicalFilterOperator Change="@((LogicalFilterOperator args) => { InvokeAsync(ChangeState); if(Auto) { InvokeAsync(Filter); } })" Size="ButtonSize.Small" class="rz-datafilter-operator-bar">
<RadzenSelectBar @bind-Value=LogicalFilterOperator Change="EventCallback.Factory.Create<LogicalFilterOperator>(this, OnFilterOperatorChanged)" Size="ButtonSize.Small" class="rz-datafilter-operator-bar">
<Items>
<RadzenSelectBarItem Text="@AndOperatorText" Value="LogicalFilterOperator.And" title="@AndOperatorText" />
<RadzenSelectBarItem Text="@OrOperatorText" Value="LogicalFilterOperator.Or" title="@OrOperatorText" />
Expand Down
18 changes: 16 additions & 2 deletions Radzen.Blazor/RadzenDataFilter.razor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Components;
using System;
using Microsoft.JSInterop;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -423,5 +423,19 @@ public async Task RemoveFilter(CompositeFilterDescriptor filter)
await Filter();
}
}

private async Task OnFilterOperatorChanged(LogicalFilterOperator _)
{
var inputValues = await JSRuntime.InvokeAsync<Dictionary<string, object>>("Radzen.getNumericInputValues");

await InvokeAsync(ChangeState);

await JSRuntime.InvokeVoidAsync("Radzen.setNumericInputValues", inputValues);

if (Auto)
{
await InvokeAsync(Filter);
}
}
}
}
}
33 changes: 32 additions & 1 deletion Radzen.Blazor/wwwroot/Radzen.Blazor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,37 @@ window.Radzen = {
el.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: true, keyCode: 9 }));
}
},
blurAllNumericInputs: function () {
const inputs = document.querySelectorAll('.rz-numeric-input input');
inputs.forEach(input => {
input.blur();
input.focus();
});
},
getNumericInputValues: function () {
const inputs = {};
const spans = document.querySelectorAll('span.rz-numeric');
spans.forEach((span) => {
const input = span.querySelector('.rz-numeric-input');
if (input && span.id) {
inputs[span.id] = input.value;
}
});
return inputs;
},
setNumericInputValues: function (values) {
for (const spanId in values) {
if (values.hasOwnProperty(spanId)) {
const span = document.getElementById(spanId);
if (span) {
const input = span.querySelector('.rz-numeric-input');
if (input) {
input.value = values[spanId];
}
}
}
}
},
readFileAsBase64: function (fileInput, maxFileSize, maxWidth, maxHeight) {
var calculateWidthAndHeight = function (img) {
var width = img.width;
Expand Down Expand Up @@ -2496,4 +2527,4 @@ window.Radzen = {
tooltipContent.classList.remove('rz-bottom-chart-tooltip');
tooltipContent.classList.add(tooltipContentClassName);
}
};
};
Loading