Jul 15, 2010, 1:11 PM
[CLOSED] format Numberfield
Hi, Can I add format for a xtype: numberfield?
I want to format my field to currency in this example.
This is my complete function
I want to format my field to currency in this example.
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
currencySymbol: '\u0024',
emptyText: '0.00',
validateOnBlur: true,
disabled: true,
fieldLabel: '<%= ResStr.Expense_SellingRate %>',
name: 'SellingRate',
id: 'SellingDailyRate',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldManualSelling').getValue() * hoursByDay
My example dont show $ symbol. Can I add formatNumber function or Mask("0.00$") function?This is my complete function
function initRateForm() {
rateForm = new Ext.FormPanel({
id: 'rateForm',
labelAlign: 'left',
frame: true,
header: false,
bodyStyle: 'padding:5px 5px 0',
buttonAlign: 'center',
width: 200,
labelWidth: 65,
layout: 'form',
items: [{
xtype: 'radiogroup',
hideLabel: true,
id: 'group',
columns: [100, 75],
items: [{
boxLabel: '<%= ResStr.Expense_AutomaticRate %>',
name: 'rateType',
id: 'AutoRate',
inputValue: 'auto',
checked: !Ext.getCmp('fieldIsManualRate').getValue()
},
{
boxLabel: '<%= ResStr.Expense_ManualRate %>',
name: 'rateType',
id: 'ManuRate',
inputValue: 'manu',
checked: Ext.getCmp('fieldIsManualRate').getValue(),
listeners: {
'check': {
fn: function() {
setRateFieldsVisibility();
}
}
}
}]
},
{
xtype: 'fieldset',
title: '<%= ResStr.Expense_HourlyRate %>',
width: 180,
id: 'RateTypeFieldset',
items: [{
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
emptyText: '0.00',
validateOnBlur: true,
disabled: true,
fieldLabel: '<%= ResStr.Expense_Hours %>',
name: 'Hours',
id: 'Hours',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldQuantity').getValue()
},
{
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
emptyText: '0.00',
validateOnBlur: true,
fieldLabel: '<%= ResStr.Expense_CostRate %>',
name: 'CostRate',
id: 'CostRate',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldManualCost').getValue()
},
{
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
emptyText: '0.00',
validateOnBlur: true,
fieldLabel: '<%= ResStr.Expense_SellingRate %>',
name: 'SellingRate',
id: 'SellingRate',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldManualSelling').getValue()
}]
},
{
xtype: 'fieldset',
title: '<%= ResStr.Expense_DailyRate %>',
width: 180,
id: 'RateTypeFieldset1',
items: [{
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
emptyText: '0.00',
validateOnBlur: true,
disabled: true,
fieldLabel: '<%= ResStr.Expense_Days %>',
name: 'Days',
id: 'Days',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldDayQuantity').getValue()
},
{
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
emptyText: '0.00',
validateOnBlur: true,
disabled: true,
fieldLabel: '<%= ResStr.Expense_CostRate %>',
name: 'CostRate',
id: 'CostDailyRate',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldManualCost').getValue() * hoursByDay
},
{
xtype: 'numberfield',
cls: 'rtl',
blankText: '0.00',
decimalPrecision: 2,
allowNegative: false,
allowBlank: false,
allowDecimals: true,
currencySymbol: '\u0024',
emptyText: '0.00',
validateOnBlur: true,
disabled: true,
fieldLabel: '<%= ResStr.Expense_SellingRate %>',
name: 'SellingRate',
id: 'SellingDailyRate',
width: 60,
selectOnFocus: true,
decimalSeparator: '<%= ViewData["DecimalSeparator"] %>',
value: Ext.getCmp('fieldManualSelling').getValue() * hoursByDay
}]
}]
});
}
Thanks.
Last edited by geoffrey.mcgill; Jul 15, 2010 at 7:30 PM.
Reason: code formatting