Telerik Forums
UI for Blazor Forum
1 answer
110 views

Good Morning,

I vave this code. I try to create a FluentValdation in TelerikForm, code builts good.  When i submit empty form, validations are good(), but the form doesn't show the errors.


<TelerikForm Model="@TriggerDetail" Columns="1" ColumnSpacing="25px" OnValidSubmit="@HandleValidSubmit" EditContext="@EditContext">
    <FormValidation>
        <FluentValidationValidator Validator="@Validator"></FluentValidationValidator>
    </FormValidation>    
    <FormItems>
        <FormGroup LabelText="General Information" Columns="2" ColumnSpacing="15px">
            <FormItem Field="@nameof(TriggerDetailModel.Name)" LabelText="@Localizer["JobTrigger_Name"]" Enabled="@Enabled"></FormItem>
            <ValidationMessage For="@(() => TriggerDetail.Name)" />
            <FormItem Field="@nameof(TriggerDetailModel.Group)" LabelText="@Localizer["JobTrigger_Group"]" Enabled="@Enabled">
                <Template>
                    <label class="k-label k-form-label">@Localizer["JobTrigger_Group"]</label>
                    <TelerikAutoComplete Data="@ExistingTriggerGroups" @bind-Value="@TriggerDetail.Group" ClearButton="true" Enabled="@Enabled" />
                </Template>
            </FormItem>
			<ValidationMessage For="@(() => TriggerDetail.Group)" />
		</FormGroup>
	</FormItems>
	<FormButtons>       
            <TelerikButton Icon="caret-alt-to-left" OnClick="@BackStep" ThemeColor="@(ThemeConstants.Button.ThemeColor.Error)">@Localizer["Back"]</TelerikButton>
            <TelerikButton ButtonType="ButtonType.Submit" Icon="caret-alt-to-right" ThemeColor="@(ThemeConstants.Button.ThemeColor.Info)">@Localizer["Next"]</TelerikButton>        
    </FormButtons>
</TelerikForm>
	
	
@code{
	public TriggerDetailModel TriggerDetail { get; set; } = null!;
	public TriggerDetailValidator Validator { get; set; } = new();
	
    private void HandleValidSubmit()
    {
        var validationResult = Validator.Validate(TriggerDetail);
        if (validationResult.IsValid)
        {
            NextStep();
        }
        else
        {
            //Errores
        }            
    }
}

public class TriggerDetailValidator : AbstractValidator<TriggerDetailModel>
{                
        public TriggerDetailValidator()
        {           
            RuleFor(t => t.Name).NotEmpty();
            RuleFor(t => t.Group).NotEmpty();
        }
}

Where is the problem?

 

Thanks

Svetoslav Dimitrov
Telerik team
 answered on 18 Nov 2022
1 answer
106 views
Here is the sample that shows what is the issue.
Just check any child and click "clear" button. The "full checks" are removed correctly, but indeterminate ones stays.
@* Enable the CheckParents parameter and observe the behavior of this setting. *@

<TelerikTreeView Data="@FlatData"
                 @bind-ExpandedItems="@ExpandedItems"
                 CheckParents="true"
                 CheckBoxMode="@TreeViewCheckBoxMode.Multiple"
                 @bind-CheckedItems="@checkedItems">
    <TreeViewBindings>
        <TreeViewBinding IdField="Id" ParentIdField="ParentIdValue" TextField="Text" HasChildrenField="HasChildren" IconField="Icon" />
    </TreeViewBindings>
</TelerikTreeView>

<div>
    Checked items:
    <ul>
        @if (checkedItems.Any())
        {
            foreach (var item in checkedItems)
            {
                var checkedItem = item as TreeItem;
                <li>
                    <span>
                        <TelerikIcon Icon="@checkedItem.Icon"></TelerikIcon>
                    </span>
                    <span>
                        @(checkedItem.Text)
                    </span>
                </li>
            }
        }
    </ul>
    <button @onclick="Clear">clear</button>
</div>


@code {
    public IEnumerable<object> checkedItems { get; set; } = new List<object>();

    public class TreeItem
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public int? ParentIdValue { get; set; }
        public bool HasChildren { get; set; }
        public string Icon { get; set; }
    }

    public IEnumerable<TreeItem> FlatData { get; set; }
    public IEnumerable<object> ExpandedItems { get; set; } = new List<TreeItem>();

    protected override void OnInitialized()
    {
        LoadFlatData();
        ExpandedItems = FlatData.Where(x => x.HasChildren == true).ToList();
    }

private void Clear() {
    checkedItems = new List<object>();
        StateHasChanged();
}

    private void LoadFlatData()
    {
        List<TreeItem> items = new List<TreeItem>();

        items.Add(new TreeItem()
        {
            Id = 1,
            Text = "Project",
            ParentIdValue = null,
            HasChildren = true,
            Icon = "folder"
        });

        items.Add(new TreeItem()
        {
            Id = 2,
            Text = "Design",
            ParentIdValue = 1,
            HasChildren = true,
            Icon = "brush"
        });
        items.Add(new TreeItem()
        {
            Id = 3,
            Text = "Implementation",
            ParentIdValue = 1,
            HasChildren = true,
            Icon = "folder"
        });

        items.Add(new TreeItem()
        {
            Id = 4,
            Text = "site.psd",
            ParentIdValue = 2,
            HasChildren = false,
            Icon = "psd"
        });
        items.Add(new TreeItem()
        {
            Id = 5,
            Text = "index.js",
            ParentIdValue = 3,
            HasChildren = false,
            Icon = "js"
        });
        items.Add(new TreeItem()
        {
            Id = 6,
            Text = "index.html",
            ParentIdValue = 3,
            HasChildren = false,
            Icon = "html"
        });
        items.Add(new TreeItem()
        {
            Id = 7,
            Text = "styles.css",
            ParentIdValue = 3,
            HasChildren = false,
            Icon = "css"
        });

        FlatData = items;
    }
}
Am I doing something wrong?
Dimo
Telerik team
 answered on 18 Nov 2022
0 answers
206 views

Hi,

Is there any way to add Footer Template to a column of Grid in blazor by C# code?

Vinh
Top achievements
Rank 1
 updated question on 18 Nov 2022
1 answer
152 views

I don't see a Class property on the GridColumn object.  Is there a way to style a specific column?  In my instance, i would like to remove the left border for just 1 of many columsn in the grid.

Thanks in advance.

Eric
Top achievements
Rank 2
Iron
Iron
 answered on 17 Nov 2022
2 answers
291 views

My app worked on v3.6.1 but when I upgraded to v3.7 I'm getting the error below. It has something to do with the TelerikDatePicker. If I remove the date picker it I don't get the error. Any way I can get around this?

 

fail: Microsoft.AspNetCore.Components.Web.ErrorBoundary[0]
      Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'addEventListener')
      TypeError: Cannot read properties of null (reading 'addEventListener')
          at QM.bindEvents (https://localhost:7116/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1755270)
          at new QM (https://localhost:7116/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1756185)
          at Zt (https://localhost:7116/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1029936)
          at Module.tE (https://localhost:7116/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1756262)
          at https://localhost:7116/_framework/blazor.webassembly.js:1:3332
          at new Promise (<anonymous>)
          at Object.beginInvokeJSFromDotNet (https://localhost:7116/_framework/blazor.webassembly.js:1:3306)
          at Object.St [as invokeJSFromDotNet] (https://localhost:7116/_framework/blazor.webassembly.js:1:59938)
          at _mono_wasm_invoke_js_blazor (https://localhost:7116/_framework/dotnet..oafyft2lng.js:9073:37)
          at do_icall (wasm://wasm/031ebc56:wasm-function[3582]:0xc1359)
         at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
         at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
         at Telerik.Blazor.Components.Common.Pickers.TelerikPickerBase`1.<InitPicker>d__119[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
         at Telerik.Blazor.Components.Common.Pickers.TelerikPickerBase`1.<OnAfterRenderAsync>d__115[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
Dimo
Telerik team
 answered on 17 Nov 2022
0 answers
111 views

I need a component that allows the user to enter multiple key-values.
Similar to the "properties" window in Visual Studio.

The challenge is that "value" is object type because values ​​can be of different types.

I wanted to implement this using a Grid component with the InCell editing option.
The problem, however, is the unspecified "value" type...
The edit cell would have to render a different edit component depending on the "value" type.

Do you have any idea how to accomplish this?

My test code:

<TelerikGrid Data=@MyData EditMode="@GridEditMode.Incell">
    <GridColumns>
        <GridColumn Field=@nameof(TextValue.Text) Title="Text" Editable="false" />
        <GridColumn Field=@nameof(TextValue.Value) Title="Value" Editable="true" />
    </GridColumns>
</TelerikGrid>

@code
{
    TextValue[] MyData = new TextValue[]
    {
        new TextValue { Text = "test1", Value = "test" },
        new TextValue { Text = "test2", Value = false },
        new TextValue { Text = "test3", Value = 3 }
    };

    public class TextValue
    {
        public string Text { get; set; }
        public object Value { get; set; }
    }
}

Kris
Top achievements
Rank 1
 asked on 17 Nov 2022
1 answer
163 views

I have attached a screenshot.

 

I copied documentation from:  https://docs.telerik.com/blazor-ui/components/grid/overview#creating-blazor-data-grid

 

I'm using version 2.24.0 is this why there is no styling?

Dimo
Telerik team
 answered on 16 Nov 2022
1 answer
393 views

I need to set active tab from code and handle tab changed from user interaction, so i use the ActiveTabIndex property and the ActiveTabIndexChanged event, but this prevent tab to be changed from gui.

The issue can be replied with this code:

 

<TelerikTabStrip ActiveTabIndex="ActiveTabIndex"ActiveTabIndexChanged="ActiveTabIndexChanged">

    <TabStripTab Title="Tab1">
        <Content>1</Content>
    </TabStripTab>
    <TabStripTab Title="Tab2">
        <Content>2</Content>
    </TabStripTab>
</TelerikTabStrip>
@code {

    private int ActiveTabIndex {get;set;}

 

    private void ActiveTabIndexChanged(int tabIndex)
    {
    }

}

 

what's wrong?

Thanks

Dimo
Telerik team
 answered on 16 Nov 2022
1 answer
157 views
Tabstrip titles are default red how to change their color
Hristian Stefanov
Telerik team
 answered on 15 Nov 2022
1 answer
238 views

I have a page/component using the <TelerikGridLayout> object.

I dont seem to be understanding the row tag.

 <GridLayoutRows>      
        <GridLayoutRow Height="100px"></GridLayoutRow>   @*App Msg*@
        <GridLayoutRow Height="25px"></GridLayoutRow>     @*Report Choices*@
        <GridLayoutRow Height="50px"></GridLayoutRow>
        <GridLayoutRow Height="5%"></GridLayoutRow>
        <GridLayoutRow Height="75%"></GridLayoutRow>    @*Report Grid *@
    </GridLayoutRows>

 

I have tried %s also but the same thing seems to happen.

Sometimes the 1st row is covered by the objects in the 2nd row. example:

That text msg area is on the 1st row the Labels and button are on the 2nd row.

I thought the 1st row would push the 2nd row stuff down auto like. :)

How do I get it to not cover each other?

 

Thanks

Deasun.

 

 

Dimo
Telerik team
 answered on 15 Nov 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?