Hello!
I have the following issue with the Radzen Data Grid.
I have created the following Dynamic Radzen Data Grid component to re-use in my application:
<RadzenDataGrid Data="@Data"
TItem="IDictionary<string, string>"
ColumnWidth="100px"
AllowColumnResize="true"
Style="width: calc(100vw - 380px)"
EmptyText="@emptyText"
AllowPaging="true"
IsLoading="@IsLoading">
<Columns>
@foreach (var column in Columns)
{
<RadzenDataGridColumn TItem="IDictionary<string, string>" Title="@column.Key" Type="column.Value" Property="@GetColumnPropertyExpression(column.Key, column.Value)">
<Template>
@context[@column.Key]
</Template>
</RadzenDataGridColumn>
}
</Columns>
</RadzenDataGrid>
public partial class DynamicTable
{
const string emptyText = "No records found!";
[Parameter]
public IEnumerable<IDictionary<string, string>> Data { get; set; }
[Parameter]
public IDictionary<string, System.Type> Columns { get; set; }
[Parameter]
public bool IsLoading { get; set; }
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
public string GetColumnPropertyExpression(string name, System.Type type)
{
var expression = $@"it[""{name}""].ToString()";
if (type == typeof(int))
{
return $"int.Parse({expression})";
}
else if (type == typeof(DateTime))
{
return $"DateTime.Parse({expression})";
}
return expression;
}
}
Usage:
I have issues with the EmptyText and IsLoading properties meaning that they completely don't work on my Production Env. The production env means that the Blazor web app is hosted on a K8S Pod in Azure.
My scenario is the following:
-
I am clicking a button to start the process of generating some data;
-
First thing I do in the page where I am using this component is to set the variable that goes into the IsLoading to true. Also, I am generating an empty list of columns and data and pass them to the Component. This component is also surrounded by an if statement that controls the visibility of the grid. When clicking the button I am also settings that flag to true to allow the rendering of the component. This works fine on localhost, meaning that an empty table will appear with the loading marker:
-
If the data is generated, I then set the loading flag to false and pass the generated data to the table. No issues here, the table will be re-rendered with the new columns and rows.
-
If no data is generated, I then pass and empty enumerable which allows the table to use the EmptyText property and display a text. On localhost, this works fine:
On the prod env, the loading phase is ignored completely, meaning no empty table with a loading marker is generated, and if no results come back I am only displaying a thin line: