PDA

View Full Version : Datefield Y/m bug in EXTJS ?



code_expert
31 Aug 2012, 12:35 PM
Does anyone knows if this bug has been fixed, or is there any workaround for it?
http://cnxforum.com/showthread.php?570-Datefield-Y-m-bug-in-EXTJS

The problem that I have is that the date field entry in my form with format 'Y/m' jumps to the next month if I select a month like April that doesn't have 31 days, and today is Aug 31st. So I guess the day that has been selected is 31st, and since April doesn't have 31 days, it jumps to next month.

Any idea how to work around that, and not change the format? I am using Extjs V4.1.0.

Thanks,
Shabnam

vietits
31 Aug 2012, 6:18 PM
Try to set default day to a specific value instead of using current day.


Ext.onReady(function(){
Ext.Date.defaults.d = 1; // set default day value to 1


Ext.create('Ext.window.Window', {
width:400,
height:300,
plain:true,
title:'DateField with Y/m format',
layout:'fit',
border:false,
closable:false,
items: [{
xtype: 'form',
frame: true,
header: true,
width: 450,
title: "Test Date",
labelAlign: 'right',
labelWidth: 200,
items: [{
xtype: 'datefield',
fieldLabel: 'Start date (Y/M)',
format: "Y/m",
value: '2010/01',
width: 200
}]
}]
}).show();
});