Thank you Korchev. I have been trying to follow the online demo and assume I am missing something silly. Here is my code:
'''<RadzenDataGrid @ref="CdAssignmentTypeGrid" AllowFiltering="true" AllowPaging="true" PageSize="20" AllowSorting="true"
EditMode="DataGridEditMode.Single" AllowColumnResize="true"
Data="@CdAssignmentType_Collection" TItem="CdAssignmentType" RowUpdate="@OnUpdateRow" RowCreate="@OnCreateRow">
<RadzenTextBox @bind-Value="CdAssignmentType_Singleton.Name"
Name="Name" Style="width:100%; display: block"/>
@code {
RadzenDataGrid<CdAssignmentType> CdAssignmentTypeGrid;
IList<CdAssignmentType> CdAssignmentType_Collection = new List<CdAssignmentType>();
//Lookup Values
protected override async Task OnInitializedAsync()
{
await RequeryData(true);
}
async Task RequeryData(bool forceRefresh)
{
//Step 1: Prepare Data Request
DataRequestParameters DataRqstPmtr = new DataRequestParameters()
{
BaseEntity = enumDataSource.CdAssignmentType,
ProductId = Guid.Empty,
LimitToProduct = false
};
//Step 2: Call WebApi Controller
var PostResult = await client.PostAsJsonAsync("api/genericdatarequest", DataRqstPmtr);
var resultString = await PostResult.Content.ReadAsStringAsync();
CdAssignmentType_Collection = JsonSerializer.Deserialize<IList<CdAssignmentType>>(resultString, JsonHelper.SerializationOptions);
if (forceRefresh)
{
await InvokeAsync(StateHasChanged);
}
}
void InsertRow()
{
CdAssignmentTypeGrid.InsertRow(new CdAssignmentType());
}
void EditRow(CdAssignmentType CdAssignmentType_Singleton)
{
CdAssignmentTypeGrid.EditRow(CdAssignmentType_Singleton);
}
async Task OnUpdateRow(CdAssignmentType CdAssignmentType_Singleton)
{
await client.PutAsJsonAsync("api/toolset", CdAssignmentType_Singleton);
NotificationService.Notify(new NotificationMessage()
{
Severity = NotificationSeverity.Success
,Summary = "Successful Save"
,Detail = CdAssignmentType_Singleton.Name + " was saved successfully."
,Duration = 4000
}
);
}
async Task SaveRow(CdAssignmentType CdAssignmentType_Singleton)
{
await client.PutAsJsonAsync("api/CdAssignmentType", CdAssignmentType_Singleton, JsonHelper.SerializationOptions);
NotificationService.Notify(new NotificationMessage()
{
Severity = NotificationSeverity.Success
,Summary = "Successful Save"
,Detail = CdAssignmentType_Singleton.Name + " was saved successfully."
,Duration = 4000
}
);
CdAssignmentTypeGrid.CancelEditRow(CdAssignmentType_Singleton);
await RequeryData(true);
}
async Task CancelEdit(CdAssignmentType CdAssignmentType_Singleton)
{
CdAssignmentTypeGrid.CancelEditRow(CdAssignmentType_Singleton);
await RequeryData(true);
}
async Task DeleteRow(CdAssignmentType CdAssignmentType_Singleton)
{
if (CdAssignmentType_Collection.Contains(CdAssignmentType_Singleton))
{
string ConfirmHeader = "Confirm Delete";
string ConfirmText = "Clicking 'Delete' will Remove " + CdAssignmentType_Singleton.Name;
ConfirmOptions _ConfirmOptions = new ConfirmOptions()
{
OkButtonText = "Delete",
CancelButtonText = "Cancel",
Width = "800px"
};
var confirmResult = await DialogService.Confirm(
ConfirmText, ConfirmHeader, _ConfirmOptions);
if ((bool)confirmResult)
{
await client.DeleteAsync($"api/CdAssignmentType/{CdAssignmentType_Singleton.Id}");
NotificationService.Notify(new NotificationMessage()
{
Severity = NotificationSeverity.Success
,Summary = "Successful Delete"
,Detail = CdAssignmentType_Singleton.Name + " was successfully deleted."
,Duration = 4000
}
);
await RequeryData(true);
}
}
}
async Task OnCreateRow(CdAssignmentType CdAssignmentType_Singleton)
{
await client.PostAsJsonAsync("api/CdAssignmentType", CdAssignmentType_Singleton);
}
}
'''