I have hidden the spin buttons but the up & down arrows are still incrementing & decrementing values.

In my TreeGrid I have several number columns and we don't want to use the increment / decrement / spin facility. In my column definitions I have used showSpinButton: false​ which is hiding the buttons. But I need to stop the up & down buttons which are still incrementing / decrementing the value. How do I stop this so it acts like a normal numeric textbox?


3 Replies

MP Martin Pamplin October 31, 2024 01:10 PM UTC

That should probably say up & down keys.



MP Martin Pamplin October 31, 2024 04:00 PM UTC

I see the same behavior in the demos (Local Data) when I hide the spin buttons.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team November 1, 2024 01:38 PM UTC

Hi Martin,


Greetings from Syncfusion support.


We understand that you would like to prevent changes to the numeric value on the keyboard up and down actions. This can be achieved by using the keyDownHandler within the edit parameters. Here’s a sample code snippet to illustrate this approach:

{

      field: 'duration',

      headerText: 'Duration',

      textAlign: 'Right',

      width: 140,

      editType: 'numericedit',

      validationRules: { number: true, min: 0 },

      edit: {

        params: {

          format: 'n',

          showSpinButton: false,

          keyDownHandler: function (e) {

            switch (e.keyCode) {

              case 38:

                e.preventDefault();

                break;

              case 40:

                e.preventDefault();

            }

          },

        },

      },

    },

 


Sample: https://stackblitz.com/edit/nuasbp?file=index.ts


If you need further assistance, please feel free to reach out.


Regards,

Shek


Loader.
Up arrow icon