Telerik Forums
UI for Blazor Forum
1 answer
189 views
Hi, I'm trying to implement global error handling in my blazor application using Telerik ErrorBoundary. Implementation is very simple in the MainLayout.razor I have this code
<ErrorBoundary @ref="errorBoundary">
						<ChildContent>
							@Body
						</ChildContent>
						<ErrorContent Context="ex">
							@{
								OpenNotification("Unhandled exception ocurred. Please try again later.", ThemeColor.Error, CloseAfter.Success);
								// TODO: this code is called twice!

							}
						</ErrorContent>
					</ErrorBoundary>	

Open Notification it's a private method to show error message


private void OpenNotification(string text, string theme, int closeAfter)
	{
		Notification.Instance.Show(new NotificationModel
			{
				Text = text,
				ThemeColor = theme,
				CloseAfter = closeAfter
			});
	}

so when error happens notification is shown 2 times, I set console log in this code and it's logging two times execution.

Any idea what could be the problem?

Thanks

 

Svetoslav Dimitrov
Telerik team
 answered on 02 Jan 2024
1 answer
72 views

Any chance of having the CheckParents functionality of the TreeView component in the TreeList component?

KR

Dimo
Telerik team
 updated answer on 02 Jan 2024
1 answer
143 views

I have tried the following code on the official page of the Telerik pager

<TelerikPager Total="@Games.Count"
              ButtonCount="5"
              PageSize=@PageSize
              Page=@Page
              PageSizes="@PageSizesList">

</TelerikPager>

@{

    // take and render the relevant data portion based on the pager info
    var pageData = Games.Skip((Page - 1) * PageSize).Take(PageSize).ToList();
    @foreach (Game game in pageData)
    {
        <div style="display: inline-block;border: solid;padding: 10px;margin: 10px">
            @game.GameName
        </div>
    }
}
@code {
    public List<int?> PageSizesList { get; set; } = new() { 10, 20, 30 };
    public int PageSize { get; set; } = 20;
    public int Page { get; set; } = 1;
    public List<Game> Games { get; set; }
    protected override void OnInitialized()
    {
        Games = new List<Game>();
        for (int i = 1; i <= 20; i++)
        {
            Games.Add(new Game()
                {
                    GameId = i,
                    GameName = $"Game {i}"
                });
        }
    }
    public class Game
    {
        public int GameId { get; set; }
        public string GameName { get; set; }
    }

}

The output is as follows:

 

Image 1. Output

Image 2: Items per page show all options

I've configured a PageSize of 20 with PageSizes as {5, 6, 7, 8, 9, 10, 20}, and intentionally excluded null to avoid an "All"

option in the items-per-page dropdown.

However, when the PageSize matches the total count of data (20 in this instance), the dropdown doesn't automatically

select the matching option (20).

In the second image, all dropdown options are visible, but the appropriate option (20) isn't auto-selected.

What is the solution to this issue?

Radko
Telerik team
 answered on 01 Jan 2024
1 answer
124 views

Is it possible to have TelerikGrid for Blazor configured so when grid is using inline edit, as user tabs to next cell an event is triggered so that manual updates can be done to the row data, as simplest example, cells are quantity, unitcost, gst, total so that as unitcost is changed / exited  the gst is calculated as quantity*unitcost*0.10 and total is calculated as quantity*unitcost+gst

I've been searching for  hours and I'm starting to arrive at conclusion it is not easily done.

Cheers

Steve Wark

Radko
Telerik team
 answered on 01 Jan 2024
1 answer
281 views

I have a combobox component that can draw on available properties such as "Class" and "MaxHeight." However, when I try to implement comboboxes, I see no way to disable them. Below is a portion of the RenderComboBox method. I can only avoid the error by commenting out "d.AddAttribute(302, "Enabled", "false");"

                RenderFragment item = d =>
                {
                    d.OpenComponent<ComboBoxPopupSettings>(20);
                    if (RowCount == 0) { RowCount= 20; }
                        d.AddAttribute(300, "MaxHeight", $"{(RowCount * 22).ToString()}px");
                        d.AddAttribute(301, "Class", "telCombo");
                        d.AddAttribute(302, "Enabled", "false");
                        d.CloseComponent();
                };

The above code earns me the message

"Object of type 'Telerik.Blazor.Components.ComboBoxPopupSettings' does not have a property matching the name 'Enabled'."

Indeed, when I look it up, the list of inherited members has nothing for enabling/ disabling the feature. How can i disable it?

Radko
Telerik team
 answered on 01 Jan 2024
1 answer
642 views

Adding FormItem inside the FormItems got System.ArgumentNullException: Value cannot be null. (Parameter 'For') when rendering

This is my code of course the Model and EditContext will be different.

 

<TelerikForm Model="FarsDetailSate.Model"@
ref="FormReference"
EditContext="FarsDetailSate.EditContext"
Size="@ThemeConstants.Form.Size.Medium"
Columns="1"ColumnSpacing="40px"
Orientation="FormOrientation.Vertical"
Class="mb-3 px-3">

<FormValidation>
<FluentValidationValidatorValidator="@Validator">
</FluentValidationValidator>
<TelerikValidationSummary/>
</FormValidation>

<FormItems>
<FormItem Field="@nameof(Vehicle.MotorCarrierIdentificationNumber)" 
LabelText="Carrier: " 
Enabled="FarsDetailSate.HasEditPermission" Class="col-sm-12 col-md-6 col-lg-4">
</FormItem>
</FormItems>

<FormButtons></FormButtons>
</TelerikForm>
Radko
Telerik team
 answered on 01 Jan 2024
1 answer
391 views

Hi,

 

I have a TelerikForm containing a Fluent Validator and 2 buttons.
Only one of them has to validate the form.

However, even if I set NO  code into the button's associated method, it does trigger the validation.

Seems to be a default behaviour.

How to disable it for my second button?

 

Thx in advance

 

A

Radko
Telerik team
 answered on 25 Dec 2023
1 answer
162 views

Hi there!

I have created a component (Component) that is a TileLayoutItem. It renders fine for the first time but it doesn't re-render after its properties changes (OnClickHandler).

Am I doing something wrong? The exact same code works if added directly on Main.

Running example: https://blazorrepl.telerik.com/mnbQmvlX24maslQE52

Component

<TileLayoutItem>
    <HeaderTemplate>
        <a href="#">Component<span class="k-icon k-i-caret-alt-right widget-title-icon"></span></a>
    </HeaderTemplate>
    <Content>
        @test
        <TelerikButton OnClick="@OnClickHandler">Click me!</TelerikButton>        
    </Content>
</TileLayoutItem>
@code {
    private string test = "Button was not clicked yet";
    private void OnClickHandler(MouseEventArgs args)
    {
        test = "Button was clicked at: " + DateTime.Now.ToString();            
    }
}

Main

<TelerikTileLayout Columns="1">
    <TileLayoutItems>
        <Component></Component>
        <Component></Component>
        <TileLayoutItem>
            <HeaderTemplate>
                <a href="#">TileLayoutItem<span class="k-icon k-i-caret-alt-right widget-title-icon"></span></a>
            </HeaderTemplate>
            <Content>
                @test
                <TelerikButton OnClick="@OnClickHandler">Click me!</TelerikButton>        
            </Content>
        </TileLayoutItem>
    </TileLayoutItems>
</TelerikTileLayout>
@code {
    private string test = "Button was not clicked yet";

    private void OnClickHandler(MouseEventArgs args)
    {
        test = "Button was clicked at: " + DateTime.Now.ToString();            
    }
}

Radko
Telerik team
 answered on 25 Dec 2023
1 answer
608 views

Here is the problem:

When the page first loads, the grid attempts to load the layout defined on the page. This causes a OnRead event to occur as is expected. However, the OnStateInit does NOT fire before this OnRead event. Actually, this is not entirely correct. The initial OnRead is running independent of the OnStateInit, it simply fires and it returns when it feels like it. At some point the OnStateInit fires. I load a saved GridState layout in the OnStateInit event which causes the OnRead to fire again. 

This causes a couple problems. The grid will load, and then reload as the args.GridState is set in OnStateInit. This causes ugly page flashing, and two data requests when only one is required. Even worse since both requests are async, you are not sure which layout you will get, since the last one to come back is the one you get, which can and does occur randomly.

I can return no data for the initial request in OnRead, and this does work, however I can find no reliable way inside of the OnRead event to determine which is the initial load I don't want and which is the OnRead fired from the args.GridState set in OnStateInit which I do want.

My question is, how do I prevent the initial grid data request and load?

Bryan

Radko
Telerik team
 answered on 25 Dec 2023
0 answers
98 views
after creating account and validating email i wasn't returned back to visual studio. do i just close VS and start again?
Paul
Top achievements
Rank 1
 asked on 24 Dec 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?