1. #1
    Sencha Premium Member
    Join Date
    Aug 2011
    Posts
    3
    Vote Rating
    0
    NealHaggard is on a distinguished road

      0  

    Default Unanswered: Showing Currency in a Form

    Unanswered: Showing Currency in a Form


    I'm trying to display the currency that a number field is in somewhere in my field. It can be before the textfield, after the label, or even in the textfield (but I know that breaks the HTML5 number field, so that's fine).

    How would I go about either putting the currency symbol before the textfield or at the end of the label?

    Code:
    fields = {
                    xtype: 'fieldset',
                    items: [
                       {
                               name : 'amount',
          label: 'Amount',
          xtype: 'numberfield',
                                labelAlign: 'left',
                                labelWidth: '40%',
          required: false
       }
                 ]
    };
    My model looks like this:

    Code:
    amountModel = Ext.regModel("app.models.Amount", {
           fields: [
          {name: "amount", type: "int"},
          {name: "currencySymbol", type: "string"}
       ]
    };
    How do I either refer to the model's currencySymbol in the Label, or somehow display it to the left of the textfield?

  2. #2
    Touch Premium Member
    Join Date
    Mar 2011
    Location
    New Jersey, USA
    Posts
    130
    Vote Rating
    0
    Answers
    4
    jjerome is on a distinguished road

      0  

    Default


    if you create your form after your currency store is loaded, you can retrieve the currencySymbol and add it to the label. for example:

    Code:
    load: function(store, array)){
         symbol = array[0].data.currencySymbol;  //get the symbol
    
         ... //code setting up formPanel and other goodies
    
        //and you can use this like:   label: 'Amount' + symbol,
    
         ... //rest of the code
    }
    I wouldn't advise putting the symbol in the textfield, though.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2011
    Posts
    3
    Vote Rating
    0
    NealHaggard is on a distinguished road

      0  

    Default


    Thanks for the speedy reply, I'll give that a try!

Thread Participants: 1