jQWidgets Forums

jQuery UI Widgets Forums Grid jqxGrid with numberinput not allowing decimal digits

This topic contains 4 replies, has 2 voices, and was last updated by  Hristo 4 years, 3 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • jgarcias
    Participant

    Hi Team

    I have a grid with a column type numberinput and I want it to receive 2 decimal digits in case the currency selected (in another control out of the grid) is ‘USD’, but no decimal digits for the whole widget if the currency is different.
    The currency variable is set before the grid rows are inserted.

    This is my code for that column:

    {
       text: 'Monthly income', dataField: 'income', width: 120, columntype: 'numberinput',
       renderer: function (text, align) {
          return '<div class="gridHeader">' + text + '</div>';
       },
       initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
          if (currency == 'USD') {
             editor.decimalDigits = 2;
          }
          else {
             editor.decimalDigits = 0;
          }
       },
       createeditor: function (row, cellvalue, editor, cellText, width, height) {
          editor.jqxNumberInput({
             digits: 12,
             inputMode: 'advanced',
             spinButtons: false,
             value: 0,
             width: 120
          });
       }
    },
    

    Any advice?


    jgarcias
    Participant

    I must say that I am using:
    jQWidgets v9.1.6 (2020-May)

    If the currency is other than USD it works fine, else no decimal digits are received, only integer numbers which is not the desired effect.


    Hristo
    Participant

    Hello jgarcias,

    I would like to suggest you look at this demo:
    https://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/cascadingediting.htm?light
    You could try to use this approach to change the value in the next cell if I understand you right.
    The initeditor callback could be useful.
    Please, provide us with more details if this does not help you or if you have any other questions.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    jgarcias
    Participant

    Hi Hristo

    Ok perhaps I did not explain my issue correctly. I want the user to enter a monthly income in a column with 2 decimal digits, only if the variable currency = 'USD'. If not, the monthly income column should not allow to input decimal places.

    I have tried setting the condition for editor.decimalDigits property in initeditor or createeditor events, but with no luck, because the numberinput column always accepts only integer numbers. What can I do for the numberinput column to accept decimal digits conditionally?.

    Hope this clarifies my situation.

    Cheers.


    Hristo
    Participant

    Hello jgarcias,

    Please, take a look at this example:
    http://jsfiddle.net/1mqabepy/

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.