I have a grid that is needs to use EditMode=GridEditMode.Incell. I have a Telerik CheckBox defined under Template for a GridColumn. In order to prevent the need to click twice on the checkbox in the grid (click once to enter edit and click again to actually change the state of the checkbox to checked/unchecked), I have to set the GridColumn to Editable=false and then use OnChange to set the model value:
<TelerikGrid @ref="@BookingEquipmentGridRef"
Data="@BookingEquipmentList"
EditMode="@GridEditMode.Incell"
OnEdit="@OnEquipmentEdit"
OnRowClick="@OnEquipmentRowClick"
OnRowRender="@OnRowRenderHandler"
OnUpdate="@OnEquipmentUpdate"
OnStateInit="@((GridStateEventArgs<BookingEquipmentModel> args) => OnEquipmentGridStateInit(args))"
Height="226px"
Size="@ThemeConstants.Grid.Size.Small"
SelectionMode="GridSelectionMode.Single"
SelectedItems="@SelectedEquipmentList"
FilterMode="GridFilterMode.FilterMenu"
Resizable="true"
Sortable="true"
Reorderable="true"
Pageable="true"
EnableLoaderContainer="false"
PageSize="25">
<GridColumns>
<GridColumn Field=@nameof(BookingEquipmentModel.IsChassis) Title="Chassis" Editable="false" Filterable="false" Width="5rem">
<Template>
@{
var bem = (BookingEquipmentModel)context;
}
<TelerikCheckBox Value="@bem.IsChassis" ValueExpression="@(() => bem.IsChassis)" ValueChanged="@((bool newValue) => OnChassisChanged(newValue, bem))" />
</Template>
</GridColumn>
</GridColumns>
</TelerikGrid>
Because I have to set Editable=false the OnEdit event is not fired so I no longer can use args.IsCancelled = true to prevent cell update. In my OnChassisChanged I can not assigned the value to the model but the visual state will no longer match.
private Task OnChassisChanged(bool newValue, object item)
{
if (item == null) return Task.CompletedTask;
BookingEquipmentModel selectedEquipmentModel = (BookingEquipmentModel)item;
if (EditableState(SelectedBooking, selectedEquipmentModel) == BookingEquipmentState.EditableStatus.No) return Task.CompletedTask;
selectedEquipmentModel.IsChassis = newValue;
selectedEquipmentModel.IsEdit = true;
DataState.State = DataState.States.UnSaved;
return Task.CompletedTask;
}
My users were complaining about having to click twice on a checkbox to set it's new state (checked or unchecked) ... and I agree with their issue, but I can't seem to find a solution (and keep using the TelerikCheckBox) ... any suggestions?
I seem to recall reading another thread from some other user having similar problem, but seem unable to locate it again.