RadzenSelectBar - problem with dinamic change 'Disable' property

Hi,
i need to disable RadzenSelectBarItem when in other controls are specific values. In other control i used property Change. This is used in column in gridcontrol.

The method that changes the variable is fired:

And in RadzenSelectBar on RadzenSelectBarItem i have setted: Disabled="@_disabledAcceptanceCalendarDays" />

Unfortunately, it doesn't work very well. I'm uploading a video showing what the problem is: https://youtu.be/KOdncd2O2Ok

am I doing something wrong? thx.

In your first code screenshot Disabled property is bound to @Disabled not to @_disabledAcceptanceCalendarDays, maybe that's the problem.

Thx but this is other control. This is used to check, that i can choose second value in my first control.

In other control i used property Change.

when I change the value here, it is checked whether I can select the second value in the control that has the problem. In the CalcAcceptance() method

the control where the problem is looks like this:

I removed the Disabled property for testing. Unfortunately there is no improvement. The control still behaves strangely after a few clicks. Now it looks like this:

The problem still occurs as in the video:

I have prepared a simple code that shows what the problem is. Sometimes it works fine. But you may notice that a square stops being active or becomes active only after an action on that square.

New video for this code: https://youtu.be/x1PiPvaVDqQ

@page "/select-bar-test"

<RadzenCard>
    <RadzenDataGrid @bind-Data="@Items" TItem="GridItem" class="mt-4 w-100">
        <HeaderTemplate>
            <div class="row d-flex w-100">
                <div class="col-auto p-2 justify-content-end bd-highlight">
                    <RadzenSelectBar class="bg-white rounded-pill my-auto" TValue="int" Size="ButtonSize.Small" @bind-Value="@SelectedAnimal">
                        <Items>
                            <RadzenSelectBarItem Value="1" Text="Cat " Disabled="@_disableCat" />
                            <RadzenSelectBarItem Value="2" Text="Birds" />
                        </Items>
                    </RadzenSelectBar>
                </div>
            </div>
        </HeaderTemplate>
        <Columns>
            <RadzenDataGridColumn Title="Name" Property="Name" TItem="GridItem" />
            <RadzenDataGridColumn Title="Action" TItem="GridItem">
                <Template Context="data">
                    <div class="d-flex justify-content-center">
                        <RadzenSelectBar class="bg-white rounded-pill my-auto" TValue="int" Size="ButtonSize.Small" @bind-Value="@data.Action" Change="() => CheckHeader()">
                            <Items>
                                <RadzenSelectBarItem Value="1" Text="Eats food" />
                                <RadzenSelectBarItem Value="2" Text="drinks water" />
                                <RadzenSelectBarItem Value="3" Text="flaps wings" />
                            </Items>
                        </RadzenSelectBar>
                    </div>
                </Template>
            </RadzenDataGridColumn>
        </Columns>
    </RadzenDataGrid>

</RadzenCard>

@code {
    public List<GridItem> Items { get; private set; }
    public int SelectedAnimal { get; private set; }

    private const int _flapsWingsAction = 3;
    private const int _birdAnimal = 2;

    private bool _disableCat;

    protected override async Task OnInitializedAsync()
    {
        Items = new List<GridItem>
        {
            new() { Name = "Animal Action", Action = 1 },
            new() { Name = "Animal Action", Action = 2 }
        };
    }

    private async Task CheckHeader()
    {
        _disableCat = false;
        if (Items.Any(x => x.Action == _flapsWingsAction))
        {
            _disableCat = true;
            SelectedAnimal = _birdAnimal;
        }
    }

    public class GridItem
    {
        public string Name { get; set; }
        public int Action { get; set; }
    }
}

It will be fixed in our next update early next week:

1 Like