We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Disable step/spin (ShowSpinButton) button but default

Is there a way to globally set ShowSpinButton=false on numeric text box? There has never been a time I want this enabled and would prefer to enable it manually if needed instead of disable it always.


3 Replies

SP Sureshkumar P Syncfusion Team January 20, 2023 09:12 AM UTC

Hi Michael,

Based on the information you've provided; it appears that you would like to enable or disable the spin button property once in all available numerictextbox component in single page. Please confirm your requirement. Based on your confirmation we will validate and update the solution.


If we have misunderstood your requirement, please provide us with more details, including a video demonstration, so we can assist you further.

Regards,

Sureshkumar P



MD Michael Dwyer January 20, 2023 01:52 PM UTC

I want it disabled ALL the time by default on the entire site, and if I wish to enable it in a certain page then I can.  But, I also should have been more specific as it is when I use it in a grid that I would like to avoid all the extra code that I have to include every time:

EditorSettings="@(new NumericEditCellParams() {Params = new Syncfusion.Blazor.Inputs.NumericTextBoxModel<object>(){ShowSpinButton=false}})"


I realize I can set that in a variable, I was just curious if there was any way to not have it default to on since I never use the steps anyways on any page (or very very rarely)



MS Monisha Saravanan Syncfusion Team January 23, 2023 02:11 PM UTC


Hi Michael,


We suspect that you are expecting to switch the ShowClearButton dynamically. We would like to inform that it is impossible to switch the values dynamically. Instead we suggest you to use an flag variable and based on the ariable we can render an new set of NumericTextBox component. Kindly check the attached code snippet for your reference.



<button @onclick="@click">change</button>

<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315">

    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>

    <GridColumns>

        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="120">

            <EditTemplate>

                @if (IsEnable)

                {

                    <SfNumericTextBox TValue="  double?" ID="Freight" @bind-Value="@((context as Order).Freight)" ShowClearButton="true">

                    </SfNumericTextBox>

                }

                else

                {

                    <SfNumericTextBox TValue="  double?" ID="Freight" @bind-Value="@((context as Order).Freight)" ShowClearButton="false">

                    </SfNumericTextBox>

                }

            </EditTemplate>

        </GridColumn>

    </GridColumns>

</SfGrid>

 

@code{

    public bool IsEnable { get; set; } = false;

    public void click()

    {

        @if (IsEnable)

        {

            IsEnable = false;

        }

        else

        {

            IsEnable = true;

        }

    }

   }


Reference: https://blazor.syncfusion.com/documentation/datagrid/cell-edit-types#using-numerictextbox-in-edittemplate


Please let us know if you have any concerns.


Regards,

Monisha


Loader.
Live Chat Icon For mobile
Up arrow icon