when using an HttpClient and set Multiple selection property true and AllowVirtualization [RadzenListBox],
throws an hard exception.
Error: System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.Generic.List1.Enumerator.MoveNext()* *at System.Linq.Enumerable.SelectListIterator2.MoveNext() at System.Linq.Enumerable.CastIterator[TResult](IEnumerable source)+MoveNext()
*at Radzen.DropDownBase`1.SelectItemFromValue(Object value) * in ...\radzen-blazor\Radzen.Blazor\DropDownBase.cs:line 950
It tries to change the list in the same time as the list is read.
A quick fix would be to copy the list.
//Change from foreach (object v in values)
//To foreach (object v in values.ToList())
The method name is "SelectItemFromValue(object value)" in "DropDownBase" class
But this is not a clean solution.
I unfortunately do not have time for a clean solution and pull request
I hope the bug can be fixed quickly.
I have looked at this now.
The problem with asynchronous processing is the two-way binding value property.
At the same time a value is set multiple and read by forearch.
This triggers the exception.
@bind-Value=@values
DataBoundFormComponent<T> CLASS
[Parameter]
public object Value
{
get
{
return _value;
}
set
{
if (_value != value)
{
_value = object.Equals(value, "null") ? null : value;
}
}
}
FIX
DropDownBase<T> CLASS
protected virtual void SelectItemFromValue(object value)
{
if (value != null && View != null)
{
if (!Multiple)
{
//......
}
else
{
/*NEW*/
var values = value as IEnumerable<object>;
/*CURRENT*/
//var values = value as dynamic;
if (values != null)
{
if (!string.IsNullOrEmpty(ValueProperty))
{
/*NEW*/
foreach (object v in values.ToArray())
/*CURRENT*/
//foreach (object v in values)
{
//......
}
}
else
{
//......
}
}
}
}
else
{
selectedItem = null;
}
}
It is accessed read only you can make a shallow copy with ToArray().
It solves the problem.
When the second dataset is loaded after scroll down, the select all checkbox is not deselected until I select an item from the list. Sometimes it works but usually it does not work.
Sometimes the behavior is also different.
Is difficult to explain