EXT js Form: Auto load datefield
Submitted by tuan.norlida on Sun, 10/24/2010 - 11:23
Codes showed below use to set auto-complete datefield if depending on combobox item.
Case:
Select 'tempoh sah jawatan' in combobox, display tarikh sah jawatan in tarikh sah jawatan field depending on months selected. Eg:
Tarikh Mula: 1/10/2010
Tempoh Sah Jawatan: 3 bulan (from tarikh mula)
Tarikh Sah Jawatan: 01/01/2011 (auto display)
TempSahJawField = new Ext.form.ComboBox({
id:'TempSahJawField',
name: 'kodtemp_sah_jaw',
fieldLabel: 'Tempoh Sah Jawatan',
valueField:'kodtemp_sah_jaw',
store: tempsahjawStore,
displayField: 'temp',
typeAhead: true,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Sila Pilih',
title: 'Bulan',
selectOnFocus: true,
anchor:'55%'
});
//Counting
TempSahJawField.on( 'select', function(){
var tarikhMula = TarikhmulaField.getValue();
var tarikh = new Date( tarikhMula );
tarikh.setMonth( tarikh.getMonth() + parseInt( TempSahJawField.getRawValue() ));
TarikhsahjawField.setValue( tarikh );
});
//Auto display
TarikhsahjawField = new Ext.form.DateField({
id:'TarikhsahjawField',
name: 'tarikh_sah',
autoLoad: true,
fieldLabel: 'Tarikh Sah Jawatan',
valueField:'tarikh_sah_jaw',
format : 'd/m/Y',
anchor:'65%'
});
- tuan.norlida's blog
- Login to post comments
Copyright © 2008-2011