How to put a maximum of decimals to a column in my grid?

I am defining the options of my grid, but I need that when editing, it only allows the user to enter 2 decimal places, how can I achieve it?


This was my failed attempt:


{
'field': "det_valor",
'headerName': 'Valor',
'headerText': 'Valor',
'textAlign': 'Right',
'edit': {'params': {'change': 'funChange'}},
'validationRules': {'required': True },
'format': '###0.#0',
'editType': 'numericedit',
'width': 200,
},



1 Reply

RR Rajapandi Ravi Syncfusion Team March 30, 2022 01:21 PM UTC

Hi Luis,


Greetings from Syncfusion support


We have checked your shared information and we could see that currently your numerictextbox is restricted and allows only two decimals, but you like to add more decimals. Based on your query we suspect that you are setting decimal property in numeric edit params. If the validateDecimalOnType is set as true, it restricts the number of decimals to be entered in the NumericTextBox.


So, we suggest you set validateDecimalOnType as false, the number of decimals will not be restricted. Please refer to the below code example and sample for more information.


 

let grid: Grid = new Grid(

        {

            dataSource: orderDataSource.slice(0,5),

            editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition: 'Top' },

            allowPaging: true,

            pageSettings: { pageCount: 5 },

            toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],

            actionBegin: actionBegin,

            columns: [

                {

                    field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID', textAlign: 'Right',

                    validationRules: { required: true, number: true }, width: 140

                },

                {

                    field: "det_valor",

                    headerText: 'Valor',

                    format: '###0.#0',

                    edit: { params: {validateDecimalOnType: false,  format: '###0.#0', decimals: 2 } },

                    editType: 'numericedit',

                    width: 200,

                }

                 .  .  .  .  .  .  .  .  .  .  .  .

                 .  .  .  .  .  .  .  .  .  .  .  .

                }],

        });

    grid.appendTo('#Grid');

 


Sample: https://stackblitz.com/edit/nwmpr9-r98rew?file=index.ts


Documentation: https://ej2.syncfusion.com/documentation/numerictextbox/getting-started/#precision-of-numbers


Screenshot:



If you still face any issues, please share the below details that will be helpful for us to provide a better solution.


1)        Please share your sample datasource structure, we would like to check what type of values you are displaying in your Valor column.


2)        Please share any issue reproducible sample or try to reproduce the issue with our above-attached sample.


Regards,

Rajapandi R


Loader.
Up arrow icon