I'm not sure what happened when I worked on this feature a few months ago this worked now its not showing the edit fields as expected.
I've found a few other posts dealing with a LoadData implementation but this version is using the demo structure so I'm at a loss why it stopped working. I just made sure that I was using the most updated version of radzen.blazor.js as I currently have to use the static file for my current implementation.
after add clicked
@if (!HasBeenProposed)
{
<RadzenButton Icon="add_circle_outline" style="margin-bottom: 10px" Text="Add" Click="@InsertRow" Disabled=@(newProspectSvcs != null) />
}
<RadzenDataGrid @ref="_prospectSvcsGrid"
AllowVirtualization="true"
AllowFiltering="true" AllowPaging="true" PageSize="3" AllowSorting="true" EditMode="DataGridEditMode.Single"
Data="@_prospectSvcsData" TItem="ProspectSvcs" RowUpdate="@OnUpdateRow" RowCreate="@OnCreateRow">
<Columns>
<RadzenDataGridColumn TItem="ProspectSvcs" Property="ServicesId" Title="Services">
<Template Context="prospectSvcsData">
@prospectSvcsData.Services?.ServiceAbbrAndName
</Template>
<EditTemplate Context="prospectSvcsData">
<RadzenDropDown Name="Service" class="form-control form-control-sm"
@bind-Value="prospectSvcsData.ServicesId"
Data="@ServiceList"
TextProperty="Name"
ValueProperty="Id"
Style="width:100%" />
<RadzenRequiredValidator Component="Service" Text="Please Select a Service" Popup="true" Style="position: absolute; margin-top: 1.5rem; z-index: 1;" />
</EditTemplate>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ProspectSvcs" Property="EstPrice" Title="EstPrice">
<Template Context="prospectSvcsData">
@DisplayFormatting.FormatCurrencyString(prospectSvcsData.EstPrice)
</Template>
<EditTemplate Context="prospectSvcsData">
<RadzenNumeric Name="EstPrice" TValue="decimal?" Format="c" @bind-Value=@prospectSvcsData.EstPrice ShowUpDown="false" />
</EditTemplate>
</RadzenDataGridColumn>
@if (!HasBeenProposed)
{
<RadzenDataGridColumn TItem="ProspectSvcs" Filterable="false" Sortable="false" TextAlign="TextAlign.Center" Width="100px">
<Template Context="prospectSvcsData">
<RadzenButton Icon="edit" Size="ButtonSize.Small" Click="@(args => EditRow(prospectSvcsData))" @onclick:stopPropagation="true">
</RadzenButton>
</Template>
<EditTemplate Context="prospectSvcsData">
<RadzenButton Icon="save" Size="ButtonSize.Small" Click="@((args) => SaveRow(prospectSvcsData))">
</RadzenButton>
<RadzenButton Icon="cancel" Size="ButtonSize.Small" ButtonStyle="ButtonStyle.Secondary" Click="@((args) => CancelEdit(prospectSvcsData))">
</RadzenButton>
</EditTemplate>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="ProspectSvcs" Context="order" Filterable="false" Sortable="false" TextAlign="TextAlign.Center" Width="70px">
<Template Context="prospectSvcsData">
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" Click="@(args => DeleteRow(prospectSvcsData))" @onclick:stopPropagation="true">
</RadzenButton>
</Template>
<EditTemplate Context="prospectSvcsData">
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" Click="@(args => DeleteRow(prospectSvcsData))">
</RadzenButton>
</EditTemplate>
</RadzenDataGridColumn>
}
</Columns>
</RadzenDataGrid>
@code {
[Parameter]
public int ProspectId { get; set; }
[Parameter]
public bool HasBeenProposed { get; set; }
RadzenDataGrid<ProspectSvcs> _prospectSvcsGrid;
IList<ProspectSvcs> _prospectSvcsData;
IList<DropDownList> ServiceList { get; set; }
protected override async Task OnInitializedAsync()
{
await LoadDataTableAsync();
}
private async Task LoadDataTableAsync()
{
_prospectSvcsData = _unitOfWork.ProspectSvcs.GetServices(ProspectId);
ServiceList = await _unitOfWork.GetDropdownAsync("Services");
}
///Prospects Services Actions
async Task EditRow(ProspectSvcs prospectSvcs)
{
await _prospectSvcsGrid.EditRow(prospectSvcs);
}
void OnUpdateRow(ProspectSvcs prospectSvcs)
{
_unitOfWork.ProspectSvcs.Update(prospectSvcs);
_unitOfWork.Complete();
}
async Task SaveRow(ProspectSvcs prospectSvcs)
{
if (prospectSvcs == newProspectSvcs)
{
newProspectSvcs = null;
}
await _prospectSvcsGrid.UpdateRow(prospectSvcs);
_prospectSvcsData = _unitOfWork.ProspectSvcs.GetServices(ProspectId);
//_prospectSvcsGrid.Reload();
}
private void CancelEdit(ProspectSvcs prospectSvcs)
{
_prospectSvcsGrid.CancelEditRow(prospectSvcs);
_unitOfWork.ProspectSvcs.CancelEdit(prospectSvcs);
_unitOfWork.Complete();
}
async Task DeleteRow(ProspectSvcs prospectSvcs)
{
if (_prospectSvcsData.Contains(prospectSvcs))
{
_unitOfWork.ProspectSvcs.Remove(prospectSvcs);
_prospectSvcsData.Remove(prospectSvcs);
_unitOfWork.Complete();
await _prospectSvcsGrid.Reload();
}
else
{
_prospectSvcsGrid.CancelEditRow(prospectSvcs);
}
}
ProspectSvcs newProspectSvcs;
private async Task InsertRow()
{
newProspectSvcs = new();
newProspectSvcs.ProspectsId = ProspectId;
await _prospectSvcsGrid.InsertRow(newProspectSvcs);
}
void OnCreateRow(ProspectSvcs prospectSvcs)
{
prospectSvcs.ProspectsId = ProspectId;
var newRow = _unitOfWork.ProspectSvcs.Add(prospectSvcs);
_unitOfWork.Complete();
}
}