Results 1 to 6 of 6

Thread: How to Display 4 Decimals for Currency Cell in a Grid

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    India
    Posts
    30
    Answers
    2
    Vote Rating
    0
      0  

    Default Answered: How to Display 4 Decimals for Currency Cell in a Grid

    Hi
    I have a field in a Grid which shows currency for example: $25.54.
    I want to change the Decimal Precision to 4 (Like $25.5432) , How can I do that. Here is my code which I am using.

    Code:
    this.columns = [ {
                text : 'Item Rate',
                width : 100,
                dataIndex : 'eRate',
                renderer: 'usMoney',            
                editor: {
                    xtype: 'numberfield',   
                    allowBlank: false,                
                    minValue: 0,
                    maxValue: 100000
                }
    Adding currencyPrecison:4 or decimalPrecision:4 doesn't work for me. The cell still shows only 2 decimal places. Can anyone please help me with a solution for this problem.

    Thanks
    FunnyFox

  2. from util/Format.js

    Code:
            /**
             * Format a number as US currency
             * @param {Number/String} value The numeric value to format
             * @return {String} The formatted currency string
             */
            usMoney : function(v) {
                return UtilFormat.currency(v, '$', 2);
            },
    maybe make your own formatter?

    Code:
      myMoney: function(v) {
          return UtilFormat.currency(v, '$', 4);
      }
    Not sure what the context is when the renderer is called, if it is the column object or the grid itself, that would decide where you drop the method.

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751
    Answers
    130
    Vote Rating
    128
      0  
    Best regards
    Tobias Uhlig

  4. #3
    Sencha Premium Member
    Join Date
    Oct 2011
    Location
    Huntsville
    Posts
    252
    Answers
    7
    Vote Rating
    -4
      0  

    Default

    from util/Format.js

    Code:
            /**
             * Format a number as US currency
             * @param {Number/String} value The numeric value to format
             * @return {String} The formatted currency string
             */
            usMoney : function(v) {
                return UtilFormat.currency(v, '$', 2);
            },
    maybe make your own formatter?

    Code:
      myMoney: function(v) {
          return UtilFormat.currency(v, '$', 4);
      }
    Not sure what the context is when the renderer is called, if it is the column object or the grid itself, that would decide where you drop the method.

  5. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    117
      0  

    Default

    Just use numbercolumn with format '$0.0000'.
    Code:
    this.columns = [ {
        xtype: 'numbercolumn',
        format: '$0.0000',
        text : 'Item Rate',
        width : 100,
        dataIndex : 'eRate',
        //renderer: 'usMoney',            
        editor: {
            xtype: 'numberfield',   
            allowBlank: false,                
            minValue: 0,
            maxValue: 100000
        }

  6. #5
    Sencha Premium Member
    Join Date
    Jun 2013
    Posts
    1
    Vote Rating
    0
      0  

    Default

    format: '$0.0000' is not a valid value, at least according to Sencha Architect.

  7. #6

    Join Date
    Mar 2017
    Location
    Lisbon
    Posts
    9
    Vote Rating
    0
      0  

    Default

    Hi All.

    I'm starting with Sencha Architect and I have some doubts. I'm trying to apply a custom currency format in a column of a grid. I'm using renderer function to do this and everything is working, but if try to use Sencha Architect IDE I don't know how to do this, because the renderer function is not "visible" and if I try to add a basic function in the columns the IDE present a popup with an error "Uncaught TypeError: cfg.getAllowOnViewController is not a function".

    Anyone knows the right way to do this in Sencha Architect?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •