I have a singleton service with a DataGrid. I would like when one user enters edit mode, that all other users get indication the row is being edited. So on the EditRowAsync call, I set an attribute on the model to indicate the model is being edited. I use the CellRender() to use the attribute and set the background color. It works on the user doing the editing, but the other users don't get the background color change. Any thoughts or better solution?
<RadzenDataGridColumn TItem="ParticipantViewModel" Frozen="true" Context="item" Pickable="false" Sortable="false" TextAlign="TextAlign.Right" Reorderable="false" Width="100px" Filterable="false">
<Template Context="item">
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Small" Click="@(args => EditRowAsync(item))" @onclick:stopPropagation="true">
</RadzenButton>
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="delete" Variant="Variant.Flat" Shade="Shade.Lighter" Size="ButtonSize.Small" class="my-1 ms-1" Click="@(args => DeleteRow(item))" @onclick:stopPropagation="true">
</RadzenButton>
</Template>
<EditTemplate Context="item">
<RadzenButton Icon="check" ButtonStyle="ButtonStyle.Success" Variant="Variant.Flat" Size="ButtonSize.Small" Click="@((args) => SaveRow(item))">
</RadzenButton>
<RadzenButton Icon="close" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Small" class="my-1 ms-1" Click="@((args) => CancelEdit(item))">
</RadzenButton>
<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="delete" Variant="Variant.Flat" Shade="Shade.Lighter" Size="ButtonSize.Small" class="my-1 ms-1" Click="@(args => DeleteRow(item))">
</RadzenButton>
</EditTemplate>
</RadzenDataGridColumn>
public async Task EditRowAsync(ParticipantViewModel model)
{
model.IsEditing = true;
if (ParticipantModelsGrid != null)
await ParticipantModelsGrid.EditRow(model);
}
public void CellRender(DataGridCellRenderEventArgs<ParticipantViewModel> args)
{
if ( args.Data.IsEditing)
{
string selected = "#ffffe0";
args.Attributes.Add("style", $"background-color: {selected};");
}
}