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>
I have a Telerik Dialog:
@using Telerik.Blazor.Components
<TelerikDialog @bind-Visible="@Visible" Width="320px" Title="Submit the page">
<DialogContent>
<div id="dialog-form-fileupload">
<div id="divMessagesFile" class="en-form-row en-message-warning">
</div>
<div class="col-md-12">
<div class="form-group">
<InputFile OnChange="@LoadFiles">
</InputFile>
</div>
<div class="form-group">
<label>Documentsoort</label>
<div>
<TelerikDropDownList Data="@DocumentTypes" TextField="Value" ValueField="Key" @bind-Value="@DocumentType" @ref="@DocumentTypesRef"
OnChange="OnDocumentTypeChanged"></TelerikDropDownList>
</div>
<div><span>@IsEnabled</span></div>
</div>
<div class="form-group">
<label>Meesturen naar aannemer</label>
<div class="form-check form-check-inline">
<TelerikCheckBox id="send-to-contractor" class="form-check-input" @bind-Value="@SentToContractor" Enabled="@IsEnabled" @ref="@SentToContractorRef" />
</div>
</div>
</div>
</div>
</DialogContent>
<DialogButtons>
<TelerikButton ButtonType="@ButtonType.Button" class="btn btn-primary ms-2" OnClick="@Save">Opslaan</TelerikButton>
<TelerikButton ButtonType="@ButtonType.Button" class="btn btn-primary ms-2" OnClick="@Cancel">Annuleren</TelerikButton>
</DialogButtons>
</TelerikDialog>
My problem is with the TelerikDropDownList and the TelerikCheckBox. In my OnDocumentTypeChanged I want to check/unchech and enable/disable the chekbox depending from the selected item in de dropdownlist.
I tried many ways but the checkbox did not change, i even put a span with the value of the IsEnabled, and also that didn't change.
However when I close the popup, and open it again, the values are correctly set
THis is the "close"function
private void Cancel()
{
Visible = false;
}
These are the OnDocumentTypeChanged functions I used but did not work
public void OnDocumentTypeChanged(object newValue)
{
var selectedItem = DocumentTypes.FirstOrDefault(item => item.Key == newValue as string);
if (selectedItem != null)
{
IsEnabled = selectedItem.OpdrachtberichtWijzigbaar;
SentToContractor = selectedItem.Opdrachtbericht;
}
StateHasChanged();
}
public async Task OnDocumentTypeChanged(object newValue)
{
var selectedItem = DocumentTypes.FirstOrDefault(item => item.Key == newValue as string);
if (selectedItem != null)
{
IsEnabled = selectedItem.OpdrachtberichtWijzigbaar;
SentToContractor = selectedItem.Opdrachtbericht;
}
await InvokeAsync(StateHasChanged);
return Task.CompletedTask;
}
public async Task OnDocumentTypeChanged(object newValue)
{
var selectedItem = DocumentTypes.FirstOrDefault(item => item.Key == newValue as string);
if (selectedItem != null)
{
await InvokeAsync(() =>
{
IsEnabled = selectedItem.OpdrachtberichtWijzigbaar;
SentToContractor = selectedItem.Opdrachtbericht;
});
// Trigger a UI update
StateHasChanged();
}
}
But I always get the same resutl, the checkbox' state is not changed only when i close the dialog and reopen it.
I also tried to close the dialog within the OnDocumentTypeChanged, by putting Visible = false; in it
And strangely, that did work, ANyone knows what I did wrong?
Hi,
I am using telerikgrid control to display the employees information. I have telerikgridcheckboxcolumn which is bind to a IEnumerable list of employee who are eligible for promotion.
I am looking for a solution to disable this header checkbox when there is none of the employee is eligible for promotion.
Please see below my code snippet for Grid and Checkbox:
<TelerikGrid Data="ShipmentInfo" SelectionMode="GridSelectionMode.Multiple" SelectedItems="SelectedEmployees" Class="grid-no-scroll" Sortable="true" Size="Telerik.Blazor.ThemeConstants.Grid.Size.Medium" Resizable="true" Pageable="false" Height="55vh" ScrollMode="GridScrollMode.Scrollable" FilterMode="GridFilterMode.None" OnRowRender="@OnRowRenderHandler" SelectedItemsChanged="@((IEnumerable<EmployeeInfoDto> employeess) => SelectedItemsChanged(employees))">
<GridCheckboxColumn Title="Allow Promotion" SelectAll="true" CheckBoxOnlySelection="true" HeaderClass="@GetHeaderCssClass()"></GridCheckboxColumn>
private void SelectedItemsChanged(IEnumerable<EmployeeInfoDto> employees)
{
// Checkboxes are disabled for shipments that aren't allowed to be routed but we don't want the select all function to select unroutable shipments
// so remove any unroutable shipments from the given collection and set that to the SelectedItems collection
SelectedEmployees = employeess.Where(s => s.EligibleForPromotion).ToList();
}
Please can you help get my desired requirement.
Thanks & regards,
Afreen
Hi,
I am using telerikgrid control to present my data on the page.
I am using a header GridCheckboxColumn to select the rows. I want to put a condition so that some rows cannot be selected (disabled for selection).
Please can someone provide some solution for this requirement.
Thanks,
Afreen
Hi,
I am using the TelerikGrid control to present the data.
I am also using a TelerikGridCheckboxColumn which is bind to a IEnumerableList. I want to disable header checkbox when all the values of IsSelected property in the list are false.
How can I do that?
Thanks,
Afreen
I recall being told I would have access to source code once I buy a licence.
Now that I have a licence, how do I get access to the source so I can do a local build?
Hi,
I'm having trouble getting a GridCheckBoxColumn to remember what was checked on page 1 of a grid, if I switch to page 2 and then back to page 1.
I can't tell from the documentation if this is expected behavior or not.
Does anyone else know if I need to write custom code here?
Rob