telerik form item getting reorder or change in order when appying conditions of controls

ykl
ykl
Member
116 Points
5 Posts

I'm using telerik for blazor in .net 8, telerik form item getting reorder or change in order when appying  conditions of controls on the basis of dropdown selection.

For example:

@if (HasCinema)
{
    <FormItem Field="@nameof(Model.Cinema)">
        <Template>
            <AnotherComponent For="@(() => Model.Cinema)" />

            <TelerikTextBox Id="state" Size="sm" Placeholder=""
            @bind-Value="@Model.Cinema"> </TelerikTextBox>
        </Template>
    </FormItem>
}
Views: 143
Total Answered: 2
Total Marked As Answer: 1
Posted On: 27-Mar-2024 01:45

Share:   fb twitter linkedin
Answers
beginer
beginer
Member
1328 Points
43 Posts
         

Try to use css to hide/show. As if we are applying if() condition item will not be constructed in the case of first time or page initialization. And again if condition get true on dropdown change event, control will be constructed in the end of form items.

We can resolve it by adding css logic something like:

In blazor page =>

<FormItem  Class="@(HasCinema?"":"hidden-item")"  Field="@nameof(Model.Cinema)">
    <Template>
        <AnotherComponent For="@(() => Model.Cinema)" />

        <TelerikTextBox Id="state" Size="sm" Placeholder=""
        @bind-Value="@Model.Cinema"> </TelerikTextBox>
    </Template>
</FormItem>

add css =>

.hidden-item {
    display: none !important;
}
Posted On: 27-Mar-2024 23:13
thanks.
 - ykl  07-Apr-2024 22:16
ykl
ykl
Member
116 Points
5 Posts
         

Thanks, works for me.

Posted On: 07-Apr-2024 22:17
 Log In to Chat