Telerik Forums
UI for Blazor Forum
1 answer
48 views

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>

Dimo
Telerik team
 answered on 14 Feb 2024
1 answer
132 views
How would I create a custom reusable component using Blazor Grid?  I have the following that I'd like to create a component from:

<TelerikGrid    Data="@InitialLendersData"
EditMode="@GridEditMode.Incell"
SelectionMode="@GridSelectionMode.Multiple"
@bind-SelectedItems="@SelectedInitialLenders"
Height="250px"
Width="640px"
OnEdit="@EditInitialLendersHandler"
OnUpdate="@UpdateInitialLendersHandler">
<GridColumns>
<GridColumn Field="@nameof(Lender.IsSelected)" Title="" Width="50px" TextAlign="@ColumnTextAlign.Center" Editable="false">
<Template>
@{
EditedLender = context as Lender;
<TelerikCheckBox @bind-Value="@EditedLender.IsSelected" OnChange="@ChangeSelectedHandler" />
}
</Template>
</GridColumn>
<GridColumn Field="@nameof(Lender.Name)" Editable="false" />
<GridColumn Field="@nameof(Lender.Amount)" Width="160px" DisplayFormat="{0:C2}" TextAlign="@ColumnTextAlign.Right">
<EditorTemplate>
@{
var item = context as Lender;
<TelerikNumericTextBox @bind-Value="@item.Amount" DebounceDelay="0" Min=0 Max=999999999999 Arrows="false" Format="C2" Decimals="2"></TelerikNumericTextBox>
}
</EditorTemplate>
</GridColumn>
</GridColumns>
</TelerikGrid>


How do I pass in the data (InitialLendersData & SelectedInitialLenders) and references to the events (EditInitialLendersHandler, UpdateInitialLendersHandler & ChangeSelectedHandler) from the custom component?  Is this possible? 
Dimo
Telerik team
 answered on 20 Dec 2023
1 answer
99 views
Checkbox shows default tabindex="-1" but would like for users to be able to tab through grid
Dimo
Telerik team
 answered on 19 Oct 2023
1 answer
50 views
The blazor TelerikCheckBox do not implement the Name property as TelerikTextBox do instead.

I need to use it in a native html form to post login values to an action for cookie authentication.

Is there any way to add the name attribute?
Nadezhda Tacheva
Telerik team
 answered on 01 Sep 2023
1 answer
200 views

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?

Hristian Stefanov
Telerik team
 answered on 17 Aug 2023
1 answer
110 views

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

Hristian Stefanov
Telerik team
 answered on 20 Apr 2023
1 answer
58 views

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

Hristian Stefanov
Telerik team
 answered on 13 Apr 2023
1 answer
94 views

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

Hristian Stefanov
Telerik team
 answered on 13 Apr 2023
1 answer
69 views

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

Dimo
Telerik team
 answered on 24 Nov 2022
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?