I am using code from the Grid inline-editing https://blazor.radzen.com/datagrid-inline-edit where I can add \delete\modify records. I added to the grid LoadData="@LoadData" to reload data based on the timer callback. Updates on a callback func are working, but now I can not use Add/Delete buttons. Please help.
1.
<RadzenGrid @ref="@recordsGridAHR" AllowFiltering="true" AllowPaging="true" AllowSorting="true" EditMode="DataGridEditMode.Single"
TItem="AHRecord" RowUpdate="@OnUpdateRow" RowCreate="@OnCreateRow" Data="@records" Count="@count" PageSize="12" LoadData="@LoadData">
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
var timerAHR = new Timer(new TimerCallback(_ =>
{
InvokeAsync(recordsGridAHR.Reload);
}), null, 20000, 20000); //20 sec test
}
}
- async Task LoadData(LoadDataArgs args)
{
records = ser.GetAHRecords(ref count);
totalTeams = ser.GetTotalTeamsList();
StateHasChanged();
}
===============
Insert function also does not work if LoadData is introduce in the Grid
void InsertRow()
{
recordsGridAHR.InsertRow(new AHRecord());
StateHasChanged();
}
//called after InsertRow()
void OnCreateRow(AHRecord record)
{
records.Insert(0, record); //adds the item at front
recordsGridAHR.UpdateRow(record);
recordsGridAHR.Reload();
//saves the new record to the database
ser.SaveRecordToDBAHR(record, _user);
totalTeams = ser.GetTotalTeamsList();
}