Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #103255

    Hi I would like to be able to put decimals into a field of a GridComponent, specifically in a % input. This is the settings that I provided to the Grid Input:
    <div>
    <div> { label: ‘% Margen’, width: 100, dataField: ‘margentarifa’, allowEdit: true, editor: ‘numberInput’, cellsFormat: ‘p2’, cellsAlign: ‘right’ }</div>
    </div>
    <div></div>
    <div>Thanks in advance.</div>
    <div></div>
    <div>Kind Regards.</div>
    <div>
    <div></div>
    </div>

    #103256

    Don’t know why the <div> tags appear, sorry.

    #103257
    admin
    Keymaster

    Hi,

    A built-in input in percentage is having that behavior, because the actual number is already a decimal. For example: the data value is 0.2 = 20%. In the Grid you will see and edit 20%, but when you get the value of the cell, it will be 0.2.

    To achieve what you need, you can do the following:

      {
                        label: 'City2', dataType: 'number', cellsFormat: 'n2', editor: {
                            template: 'numberInput',
                            numberFormat: {
                                style: 'decimal',
                                minimumFractionDigits: 2
                            }
                        }, formatFunction(settings) {
                            settings.value = settings.value + '%';
                        }, dataField: 'City2', width: 120
                    },

    Best regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

    #103262

    Thank you so much!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.