Grid not refreshing when ExpandoObject data changes
I am using Blazor Data Grid and databinding to an ExpandoObject because I need to dynamically render column names based on a changing data set. In the UI, the user can select and switch between different types of data sets that have different column names. When switching between different data sets with different columns, the new data loads properly but the old column names persist instead of updating with new column names.
Switching between data sets that DO have the same column names works just fine.
Example, initial data set selected:
Selecting new data set (which should have different column names, but the columns don't change and the data doesn't match the column name):
Expectation for this data set (active daily census):
I have tried calling Grid.Refresh(), StateHasChanged, and Grid.ResetPersistDataAsync(), but nothing has helped.
Code for Grid:
<SfGrid @ref="Grid" DataSource="@AuthDynamic" AllowResizing="true" AllowSelection="true" AllowFiltering="true" AllowSorting="true" Toolbar="@Toolbaritems">
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridEvents OnDataBound="DataBoundHandler" RowSelected="ReviewAuth" TValue="ExpandoObject" OnToolbarClick="ToolBarClickHandler"></GridEvents>
<GridColumns>
@if (AuthDynamic != null && AuthDynamic.Any())
{
var firstItem = AuthDynamic.First();
var dictionaryItem = (IDictionary<string, object>)firstItem;
var fields = dictionaryItem.Keys;
foreach(var item in dictionaryItem)
{
<GridColumn Field="@item.Key" AutoFit=true></GridColumn>
}
}
</GridColumns>
</SfGrid>
protected override async Task OnInitializedAsync()
{
try
{
var data = authService.GetAuthReviewDynamicData(userStateProvider.User.Id, ipa, PermissionID);
AuthDynamic = data.Cast<ExpandoObject>().ToList<ExpandoObject>();
}
catch (Exception e)
{
NavManager.NavigateTo("/Error");
}
}
public async Task ToolBarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
try
{
int newQueue = int.Parse(args.Item.Id);
// await Grid.ResetPersistDataAsync();
var data = authService.GetAuthReviewDynamicData(userStateProvider.User.Id, ipa, newQueue);
this.AuthDynamic = data.Cast<ExpandoObject>().ToList<ExpandoObject>();
this.QueueType = args.Item.Text;
}
catch (Exception)
{
throw;
}
}
public void DataBoundHandler(BeforeDataBoundArgs<ExpandoObject> args)
{
var GridColumns = Grid.Columns;
foreach (var column in GridColumns)
{
if (column.Field == "Request Date")
{
column.Type = ColumnType.Date;
column.Format = "d";
}
if (column.Field == "Review")
{
column.Template = data =>
{
{
var auth = data;
return@<div>
<button class="review-btn">Review</button>
</div>
;
}
};
}
}
}
Hi Lorna Grajek,
Based on
the information you shared, we attempted to reproduce the issue on our side,
but we were unable to replicate it. For your reference, we have attached the Gif
file and sample.
|
|
To proceed further with the investigation, we kindly request the following additional information:
•
Please share your attempt to reproduce the issue using the sample.
• Could you provide a simple, reproducible
sample with dummy data that demonstrates the problem? This will help us analyze
the issue more effectively.
The
requested information will help us validate the reported issue and provide a
solution as quickly as possible. Thank you for your understanding and
cooperation.
Regards,
Prathap Senthil
can you try and reproduce this issue using code that does not explicitly define the expandoobject properties and column names? you tried to reproduce this while writing extremely different code. I am making database calls and I can't use the dot notation to define properties and column names.
Adding the "HeaderText" tag to the gridcolumn declaration worked for me:
Thanks
for the update ,
We are happy to hear that the issue has been resolved after binding the HeaderText
property on the Grid column.
However, in addition to direct DataSource binding when clicking the button, we
prepared a sample using dummy data through a service and attempted to
reproduce the issue on our end. Despite these efforts, we were still unable to
reproduce the reported issue.
Sample: Check the Attachment
To proceed further with the investigation, we kindly request the following
additional information:
•
Please share your attempt to reproduce the issue using the sample.
• Could you provide a simple, reproducible
sample with dummy data that demonstrates the problem? This will help us analyze
the issue more effectively.
The requested information will help us validate the reported issue and provide a solution as quickly as possible. Thank you for your understanding and cooperation.
Attachment: DataGrid_Sample_54b1331e.zip
- 4 Replies
- 2 Participants
-
LG Lorna Grajek
- Mar 31, 2026 06:35 PM UTC
- Apr 2, 2026 12:54 PM UTC