Results 1 to 5 of 5

Thread: Grid NumberColumn Decimal places

  1. #1
    Sencha User
    Join Date
    Feb 2014
    Location
    Dsseldorf, Germany
    Posts
    27
    Answers
    1
    Vote Rating
    0
      0  

    Default Grid NumberColumn Decimal places

    Hi,

    i want to format a grid Number Column.

    The field in the model ist float.

    Now i want to format the number like this:

    52 = 52
    52,4= 52,4
    52,123456789=52,123456789

    i try this:

    0.##########

    that shows me

    52,123456789=52,123456789
    but
    52 = 52,

    Plz Help

  2. #2
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Location
    Germany, Solingen
    Posts
    280
    Answers
    4
    Vote Rating
    3
      0  

    Default

    you can try something like this:

    if (youNumber % 1 == 0)

    to check if the number has a part behind the decimal point or not and depending on the result use different number formatters.

  3. #3
    Sencha User
    Join Date
    Feb 2014
    Location
    Dsseldorf, Germany
    Posts
    27
    Answers
    1
    Vote Rating
    0
      0  

    Default

    I Dont use a numberFormatter. its a NumberColumn in a Grid with Format.

  4. #4
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Location
    Germany, Solingen
    Posts
    280
    Answers
    4
    Vote Rating
    3
      0  

    Default

    You can always override a Grid cell using this code:

    final NumberFormat number = NumberFormat.getFormat("0.00");
    changeCol.setCell(new AbstractCell<Double>() {
    @Override
    public void render(Context context, Double value, SafeHtmlBuilder sb) {
    String style = "style='color: " + (value < 0 ? "red" : "green") + "'";
    String v = number.format(value);
    sb.appendHtmlConstant("<span " + style + ">" + v + "</span>");
    }
    });

    That's the approach I would give a try.

  5. #5
    Sencha User
    Join Date
    Sep 2014
    Posts
    28
    Vote Rating
    0
      0  

    Default

    Code:
    grid = ColdFusion.Grid.getGridObject("gridName");
     cm = grid.getColumnModel();
    var formatAmt = Ext.util.Format.numberRenderer('00,00,00,00,00,000.00');   
     cm.setRenderer(column number, formatAmt);
    grid.reconfigure(grid.getStore(),cm);
    Thanks,

    Pankaj Kumar M

Similar Threads

  1. Replies: 0
    Last Post: 18 May 2011, 8:33 PM
  2. Would like to get error if too many decimal places entered in grid cell
    By dellbell99 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 24 Mar 2011, 5:07 PM
  3. Ext.form.NumberField decimal places
    By cwells in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 21 Sep 2007, 10:56 AM

Tags for this Thread

Posting Permissions

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