1. We start by creating a simple Date Picker:
var dateField = Ext.create('Ext.form.field.Date', {
fieldLabel: 'Pick a Date',
renderTo: Ext.getBody()
});
2. Now we can use the Date Picker's setValue method to give it a value. We will use
British date formatting in this example with our date formatted as dd/mm/yyyy.
dateField.setValue('31/01/2011');
3. After running this code we see that the field doesn't understand the format and so
does not display or select a value.
4. To solve this problem we can specify the format that the date picker expects the
values being passed to the setValue method are in. We do this by using the
format configuration option.
var dateField = Ext.create('Ext.form.field.Date', {
fieldLabel: 'Pick a Date',
renderTo: Ext.getBody(),
format: 'd/m/Y'
});
dateField.setValue('31/01/2011');
5. When we run this code we see that our date field contains the correct value.
댓글 없음:
댓글 쓰기