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.
On my page I have:
<TelerikCheckBox Id="chkBxIncludeChildren"
@bind-Value="@chkBxIncludeChildren_isSelected"
Title="Check me off to include this in the data!"
Class="tooltip-target"
OnChange="@chkBxIncludeChildren_OnClick" />
and I put the following at the bottom of the page:
.k-checkbox {
/* Make the border a little darker than the default */
border-color: rgba(0, 0, 0, 0.4) !important;
}
The checkboxes box appears just as i want it.
But I now want that for my whole project. This is were I am having an issue my entry in the app.css seems to be ignored and I am not sure why.
App.css:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="@MyNavigationManager.BaseUri" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="MarginAnalysis.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet @rendermode="InteractiveServer" />
@* Telerik Stuff *@
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js"></script>
<link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" />
@* Needed for the Telerik 5.0.0 icons! *@
<link href="https://blazor.cdn.telerik.com/blazor/5.0.0/kendo-font-icons/font-icons.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="app.css" />
</head>
I put the App.ccs at the end. As far as I understand it that should make it work above teleriks theme css.
What am I missing?
Thanks
Deasun.
Whenever I add a TelerkiCheckBox to a page/component the testers complain that they can't see the border of the checkbox so I'm constantly adding the below css to my razor files:
<style>
.k-checkbox {
/* Make the border a little darker than the default */
border-color: rgba(0, 0, 0, 0.4);
}
</style>
If I add this to my app.css it doesn't get applied.
Is there any way to apply this at a global level?
I have a bool property binded in two way to a dialog checkbox.
if i change the check value, the variabile inside the dialog in binded correctly, but the variable binded in the main component in not updated.
Check this sample, if i set the check and close the dialog, the parent compoent variable is not updated.
https://blazorrepl.telerik.com/ceuZbwah44LSdBQu06
how to solve?
Main.Razor
}
CheckDialog.Razor
Hi, I have a object with a collection that I want to bind to checkboxes.
public class JasminUserAdProperties()
{
[Required]
public string Email { get; set; }
[Required]
public string Name { get; set; }
/// <summary>
/// Used for checkboxes
/// </summary>
public List<AdGroupDto> Groups { get; set; } = [];
}
And this is the form / component
@using Zeus.Shared.DTO
<TelerikWindow Width="450px" Centered="true" Visible="@(AdProperties != null)" Modal="true">
<WindowTitle>
<strong>Set Jasmin roles</strong>
</WindowTitle>
<WindowActions>
<WindowAction Name="Close" OnClick="@CancelUpdateJasminRoles"/>
</WindowActions>
<WindowContent>
<TelerikForm Model="@AdProperties" OnValidSubmit="@UpdateJasminRoles">
<FormValidation>
<DataAnnotationsValidator/>
</FormValidation>
<FormItems>
@{
<FormItem>
<Template>
<label for="selectAllCheckbox">Selected All</label>
<TelerikCheckBox Id="selectAllCheckbox"
Value="@SelectAllValue"
ValueChanged="@((bool value) => ValueChanged(value))"
Indeterminate="@SelectAllIndeterminate"/>
</Template>
</FormItem>
foreach (var group in AdProperties.Groups.OrderBy(g => g.Name))
{
<FormItem>
<Template>
<label for="@group.Id">@group.Name</label>
<TelerikCheckBox @bind-Value="@group.Selected" Id="@group.Id" Name="@group.Id"/>
</Template>
</FormItem>
}
}
</FormItems>
<FormButtons>
<TelerikButton Enabled="@CanEdit" ButtonType="ButtonType.Submit" ThemeColor="@ThemeConstants.Button.ThemeColor.Primary">Save</TelerikButton>
<TelerikButton OnClick="@CancelUpdateJasminRoles">Cancel</TelerikButton>
</FormButtons>
</TelerikForm>
</WindowContent>
</TelerikWindow>
@code {
[Parameter] public EventCallback<JasminUserAdProperties> UpdateRoles { get; set; }
[Parameter] public EventCallback CancelUpdateRoles { get; set; }
[Parameter] public JasminUserAdProperties AdProperties { get; set; }
[Parameter] public bool CanEdit { get; set; }
private bool SelectAllValue => AdProperties.Groups.All(eq => eq.Selected);
private bool SelectAllIndeterminate => AdProperties.Groups.Any(eq => eq.Selected);
private void ValueChanged(bool value)
{
AdProperties.Groups.ForEach(eq => { eq.Selected = value; });
}
private void CancelUpdateJasminRoles()
{
if (CancelUpdateRoles.HasDelegate)
{
CancelUpdateRoles.InvokeAsync();
}
}
private void UpdateJasminRoles()
{
if (UpdateRoles.HasDelegate)
{
UpdateRoles.InvokeAsync(AdProperties);
}
}
}
I am getting this error(s) in spades.
Have been looking at Bind to nested (navigation) properties in complex objects but its not for lists.
What am I doing wrong?
Can we get a Switch and Checkbox theme color property similar to the rest of the components.
😀
Hello,
I have a grid filterable with one column with FilterMenuType.CheckBoxList.
I initialize a defaut filter with OnStateInit which work fine. But when I change the filter by selecting "Select all", nothing is return. It only work when I clear the filter first.
I reproduce the issue here : https://blazorrepl.telerik.com/GokJaiFR56kNGYBW07
Am I doing something wrong with the default filter or is it a bug? I can't find anything related.
Thanks in advance
Hi,
This seems to effect most telerik components, but if for example using a TelerikCheckBox and the ValueChanged event is an async function, then the error boundry wont catch the exception. This works from basic checkboxes or if not using async.
Example:
<div>
Telerik checkbox (does NOT display any error): <TelerikCheckBox TValue="bool" ValueChanged="@OnCheck" />
</div>
<div>
Basic checkbox (displays the error): <input type="checkbox" @onchange="@OnCheck" />
</div>
@{
async Task OnCheck()
{
throw new Exception("Something went wrong!");
}
}
MainLayout:
<ErrorBoundary>
<ChildContent>
<div class="page">
<div class="sidebar">
<NavMenu />
</div>
<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
<article class="content px-4">
<TelerikRootComponent>
@Body
</TelerikRootComponent>
</article>
</main>
</div>
</ChildContent>
<ErrorContent>
ERROR!!!
</ErrorContent>
</ErrorBoundary>