Hello,
I have a blazor page with a radzen dropdown component with allowvirtualization attribute and a datagrid component with allowvirtualization also.
Does anyone know why the datagrid loaddata event does not fire?
If I comment dropdown component datagrid fires loaddata event and fill the component.
Thanks in advance
enchev
October 29, 2024, 5:46pm
2
Check our forum FAQ on how to improve your question.
<RadzenTemplateForm class="form" TItem="Input" Data="@Inputs" Submit="@HandleValidSubmit" Context="context1">
<RadzenDropDown class="form-control" Name="worker" AllowClear="@true" AllowFiltering="@true" Placeholder="Select"
AllowVirtualization="@true" LoadData="@LoadUserAsync" Count="@UserCount"
@bind-Value="@SelectedUser" Data="@Users" TextProperty="AllName"
FilterCaseSensitivity="@FilterCaseSensitivity.CaseInsensitive" />
....
....
<RadzenDataGrid @ref="@GridReference" Data="@DevicesOutput" LoadData="@LoadDataAsync" TItem="DeviceSimpleOutput" AllowVirtualization="@true" AllowMultiColumnSorting="@true"
Count="@Count" Style="400px"
AllowFiltering="@false" AllowSorting="@true" IsLoading="@IsLoading" EditMode="DataGridEditMode.Multiple">
<EmptyTemplate>
<p style="color: lightgrey; font-size: 24px; text-align: center; margin: 2rem;">No records to display.</p>
</EmptyTemplate>
<Columns>
<RadzenDataGridColumn TItem="DeviceSimpleOutput" Property="Name" Title="Name"></RadzenDataGridColumn>
<RadzenDataGridColumn TItem="DeviceSimpleOutput" Title="Ip"></RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
.....
enchev
October 29, 2024, 5:55pm
4
Jos3Web:
Style="400px"
We canβt run this code to test it however this style itβs definitely not valid.
So sorry, was a typo error
Style="height:400px"
The example is still valid correcting the error
enchev
October 29, 2024, 6:05pm
6
I donβt see anything else suspicious and to comment further I will need runnable code demonstrating the problem.
I'll create a simple runnable code and post
enchev
October 29, 2024, 6:15pm
8
You can use our demos, they are editable.
It seems to work in a new application, I'll check what can happen.
Sorry for wasting your time.
Jos3Web
October 29, 2024, 6:44pm
10
No, it fails.
When use async await to get data. The previous example i was not using async/await.
How can i show the code? Paste here?
Jos3Web
October 29, 2024, 6:47pm
11
And now it works again with async/await.
I'm going crazy
I have the same issue after 5.4.0 update, when i set data in DropDownDataGrid with enabled virtualisation i got this exception "The ParameterView instance can no longer be read because it has expired. ParameterView can only be read synchronously and must not be stored for later use.", but if disable virtualisation everything work correct.
I can't reproduce this error in the demo(
enchev
October 30, 2024, 1:43pm
13
Without runnable code demonstrating the problem we cannot help.
I finaly did it)
Code:
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12">
<RadzenLabel Text="Select Value" Component="DropDownDataGridTextValueProperties" />
<RadzenDropDownDataGrid @bind-Value=@customer Data=@customers TextProperty="@nameof(Customer.CompanyName)"
AllowVirtualization=true AllowFiltering=false PagerAlwaysVisible=false Name="DropDownDataGridTextValueProperties">
<Columns>
<RadzenDropDownDataGridColumn Property="CustomerID" Title="Customer ID" Width="60px" TextAlign="TextAlign.Center" />
<RadzenDropDownDataGridColumn Property="CompanyName" Title="Company Name" Width="150px" />
</Columns>
</RadzenDropDownDataGrid>
<RadzenButton Variant="Variant.Text" Click=@Refresh Icon="refresh" Size="ButtonSize.Small" />
</RadzenStack>
@code {
Customer customer;
List<Customer> customers = new();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
private void Refresh()
{
customers = new List<Customer>()
{
new Customer() { CustomerID = 1, CompanyName = "CompanyName1" },
new Customer() { CustomerID = 2, CompanyName = "CompanyName2" },
new Customer() { CustomerID = 3, CompanyName = "CompanyName3" }
};
customer = customers.First();
}
class Customer
{
public int CustomerID { get; set; }
public string CompanyName { get; set; }
}
}
Exception:
main point of this exception is
List<Customer> customers = new();
and
AllowVirtualization=true
enchev
October 30, 2024, 3:50pm
15
Thanks! We will do our best to release fix for this tomorrow.
1 Like
Great!
Thank you and Vitaliy for testing.
Mike
Jos3Web
October 30, 2024, 6:47pm
17
I found the mistake, at least what I think it was since fixing it now is working.
In the dropdown, the object of Data (i mean Users in code behind) was initialized to an empty array and not nullable, in this way:
private IEnumerable<User> Users = [];
Then I changed to:
private IEnumerable<User>? Users;
I don't know the reason why, but at least it works.
It seems that we can't declare and initalize the variable at the same time. It doesn't matter it is a variable or a property.
I got this exception again:
Click refresh button;
Select second or third element in DropDownDataGrid;
Click refresh button again.
Code:
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12">
<RadzenLabel Text="Select Value" Component="DropDownDataGridTextValueProperties" />
<RadzenDropDownDataGrid @bind-Value=@customer Data=@customers TextProperty="@nameof(Customer.CompanyName)"
AllowVirtualization=true AllowFiltering=false PagerAlwaysVisible=false Name="DropDownDataGridTextValueProperties">
<Columns>
<RadzenDropDownDataGridColumn Property="CustomerID" Title="Customer ID" Width="60px" TextAlign="TextAlign.Center" />
<RadzenDropDownDataGridColumn Property="CompanyName" Title="Company Name" Width="150px" />
</Columns>
</RadzenDropDownDataGrid>
<RadzenButton Variant="Variant.Text" Click=@Refresh Icon="refresh" Size="ButtonSize.Small" />
</RadzenStack>
@code {
Customer customer;
List<Customer> customers = new();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
private void Refresh()
{
customers = new List<Customer>()
{
new Customer() { CustomerID = 1, CompanyName = "CompanyName1" },
new Customer() { CustomerID = 2, CompanyName = "CompanyName2" },
new Customer() { CustomerID = 3, CompanyName = "CompanyName3" }
};
customer = customers.First();
}
class Customer
{
public int CustomerID { get; set; }
public string CompanyName { get; set; }
}
}