RadzenDataGrid: column filtering with virtualization. InvalidOperationException #969

Open
opened 2026-01-29 17:47:05 +00:00 by claunia · 0 comments
Owner

Originally created by @amoraller on GitHub (Aug 29, 2023).

If i configure RadzenDataGrid with virtuialization and use column filtering, i have System.InvalidOperationException: "The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state." some time

I think, column filter use DebounceFilter and Timer.


		protected void OnFilterKeyPress(EventArgs args, RadzenDataGridColumn<TItem> column)
		{
			Debounce(() => DebounceFilter(column), FilterDelay);
		}

		private async Task DebounceFilter(RadzenDataGridColumn<TItem> column)
		{
			string text = await JSRuntimeExtensions.InvokeAsync<string>(base.JSRuntime, "Radzen.getInputValue", new object[1] { getFilterInputId(column) });
			if (!object.Equals(column.GetFilterValue(), text))
			{
				await OnFilter(new ChangeEventArgs
				{
					Value = text
				}, column);
			}
		}

......
		protected async Task OnFilter(ChangeEventArgs args, RadzenDataGridColumn<TItem> column, bool force = false, bool isFirst = true)
		{
			column.GetFilterProperty();
			if (AllowFiltering && column.Filterable && (!object.Equals(isFirst ? column.GetFilterValue() : column.GetSecondFilterValue(), args.Value) || force))
			{
				.......
				await InvokeAsync(new Func<Task>(Reload));
				if (IsVirtualizationAllowed())
				{
					StateHasChanged();   <--- HERE
				}
			}
		}


Originally created by @amoraller on GitHub (Aug 29, 2023). If i configure RadzenDataGrid with virtuialization and use column filtering, i have `System.InvalidOperationException: "The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state."` some time I think, column filter use DebounceFilter and Timer. ```csharp protected void OnFilterKeyPress(EventArgs args, RadzenDataGridColumn<TItem> column) { Debounce(() => DebounceFilter(column), FilterDelay); } private async Task DebounceFilter(RadzenDataGridColumn<TItem> column) { string text = await JSRuntimeExtensions.InvokeAsync<string>(base.JSRuntime, "Radzen.getInputValue", new object[1] { getFilterInputId(column) }); if (!object.Equals(column.GetFilterValue(), text)) { await OnFilter(new ChangeEventArgs { Value = text }, column); } } ...... protected async Task OnFilter(ChangeEventArgs args, RadzenDataGridColumn<TItem> column, bool force = false, bool isFirst = true) { column.GetFilterProperty(); if (AllowFiltering && column.Filterable && (!object.Equals(isFirst ? column.GetFilterValue() : column.GetSecondFilterValue(), args.Value) || force)) { ....... await InvokeAsync(new Func<Task>(Reload)); if (IsVirtualizationAllowed()) { StateHasChanged(); <--- HERE } } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#969