Closed lpunderscore closed 3 years ago
LoadData binding works normally on our demo: https://blazor.radzen.com/datagrid-loaddata
Can you provide more info how to reproduce the problem?
Sure, downgrading to 3.9.2 and making no other changes to the project makes it work btw. Except in 3.9.2 rowinserts go to the bottom of the grid and you have to manage them manually in the list, while in 3.9.3 they are inserted on top automatically, which is better.
EDIT: In your demo as far as I can see, you are only executing the first load. The bug is when you call SearchAsync a second time after the initial load, the grid will never update in the UI. It will only display the first set of results.
grid setup
<RadzenDataGrid @ref="_tagsGrid"
AllowFiltering="false"
AllowPaging="true"
PageSize="25"
AllowSorting="false"
EditMode="DataGridEditMode.Single"
LoadData="SearchAsync"
IsLoading="_isLoading"
Count="TagsCount"
Data="TagsList" TItem="Tag"
RowUpdate="OnUpdateRowAsync" RowCreate="OnCreateRowAsync">
<colounms>...
code behind:
public List<Tag> TagsList;
private bool _isLoading;
public int TagsCount { get; set; }
public async Task SearchAsync(LoadDataArgs args)
{
_isLoading = true;
TagsList ??= new List<Tag>();
TagsList.Clear();
var options = new SearchOptions
{
Size = 20,
IncludeTotalCount = false,
QueryType = SearchQueryType.Simple,
SearchMode = SearchMode.All
};
var results = await Mediator.Send(new Search
{
Query = SearchText,
Options = options
});
await foreach (var result in results.GetResultsAsync())
{
TagsList.Add(result.Document);
}
TagsCount = TagsList.Count;
_isLoading = false;
//none of these change anything in 3.9.3
//StateHasChanged();
//await InvokeAsync(StateHasChanged);
}
In my opinion such approach (adding items to the list) was supported by accident. Please add the items to a local variable and assign it to the list bound to Data property.
Describe the bug In version 3.9.3, DataGrid no longer updates outside of the first render.
in version previous to 3.9.3, it works changing the underlying data array and count would update the view properly. Just updating to 3.9.3 and now the view no longer updates. Tried to force with statehaschanged but nothing updates. The objects in the code all have the proper values, its just the UI not updating.
To Reproduce create a datagrid with a LoadData event and a List bound to Data
after initial load from LoadData, try to modify the dataset
the datagrid does not update.
Expected behavior The UI should reflect the new dataset
*
Desktop (please complete the following information):