Grid Inlide-edit code does not work after adding LoadData="@LoadData" to the grid

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
}
}

  1. 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();
}

Fixed the problem myself on 4/15/21.
Removed from the grid LoadData="LoadData", added Count="@count"

In the code added timer callback and set a gate - bWaitBHR to stop callback execution if a record in create/edit operations.

protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
var timerAHR = new Timer(new TimerCallback(_ =>
{
InvokeAsync(UpdateGridTableBHR);
}), null, 180000, 180000); //3 min
}
}

//updates table based on a timer callback func
protected async Task UpdateGridTableBHR()
{
    if(bWaitBHR == false)
    {

// sTimerB = GetLocalTime();
//update radzen grid
records = ser.GetRecords(ref count);
//update the HTML table total records
totals = ser.GetTotalList();
StateHasChanged();
await recordsGrid.Reload();
}
}

2 Likes