Hi everyone!
Have a problem with incell editing
I noticed that the problem started after version 5.6.0
I create special class for incell process looks like
public class EditHandler<T>
{
private string columnEditing;
public bool IsSendCallBackToParentAfterEditing;
private readonly Func<T, Task>? EditedEntityCallBack;
Func<T, string> getEntityId;
T entityToUpdate;
public EditHandler(Func<T, string> getIdFunc, Func<T, Task> _EditedEntityCallBack = null, bool _IsSendCallBackToParentAfterEditing = false)
{
getEntityId = getIdFunc ?? throw new ArgumentNullException(nameof(getIdFunc));
EditedEntityCallBack = _EditedEntityCallBack;
IsSendCallBackToParentAfterEditing = _IsSendCallBackToParentAfterEditing;
}
public void Reset()
{
if (entityToUpdate != null && IsSendCallBackToParentAfterEditing)
{
EditedEntityCallBack(entityToUpdate);
}
entityToUpdate = default;
columnEditing = null;
}
public bool IsEditing(string ColumnProperty, T entity)
{
return columnEditing == ColumnProperty && Equals(entityToUpdate, entity);
}
public void OnCellClick(DataGridCellMouseEventArgs<T> args)
{
Reset();
entityToUpdate = args.Data;
columnEditing = args.Column.Property;
}
public void Update(Action<T> onUpdateRow)
{
if (entityToUpdate != null)
{
onUpdateRow?.Invoke(entityToUpdate);
}
Reset();
}
}
main idea in callback after editing entity and process anything in a specific method and universal class for incellEditing
but after 5.6.х versions this code not work and grid cell is not activated
usage looks like
WeekDaysTableEditHandler = new EditHandler(x => x.workShift.Id, EditedShit, true); (in OnInitialized)
where EditedShit is a method for callback after editing in grid
and grid
<RadzenDataGrid @ref=@shiftCountCouplesGrid TItem="ShiftCountCouple" Data="@shiftCountCouples" Density="Density.Compact"
ColumnWidth="200px" CellClick="@WeekDaysTableEditHandler.OnCellClick" AllowAlternatingRows="false">
<Columns>
<RadzenDataGridColumn Width="auto" TItem="ShiftCountCouple" Title="Зміна" TextAlign="TextAlign.Center" >
<Template Context="data">
<RadzenBadge Style="@($"background-color:{data.workShift.Color};color: {data.workShift.TextColor};justify-content:center; align-items:center")">
@data.workShift.Name
</RadzenBadge>
</Template>
<FooterTemplate>
total
</FooterTemplate>
</RadzenDataGridColumn>
<RadzenDataGridColumn Width="auto" TItem="ShiftCountCouple" Property="Count" Title="Count" TextAlign="TextAlign.Center" IsInEditMode="WeekDaysTableEditHandler.IsEditing">
<Template Context="data">
@data.Count
</Template>
<EditTemplate Context="data">
<RadzenNumeric @bind-Value="data.Count" Style="width:100%" Min="0" TValue="int" Change="CalculateShift" />
</EditTemplate>
<FooterTemplate>
@shiftCountCouples.Sum(c => c.Count)
</FooterTemplate>
</RadzenDataGridColumn>
......OtherColumns
</Columns>
</RadzenDataGrid>
maybe anybody know what was changed the logic of datagrid after 5.6.0 version
Thx for your time