PDA

View Full Version : [OPEN] [FIXED-1388] vtype:"daterange" can't be used more than once



kyrillos52
1 Nov 2010, 2:33 AM
Hello,

I've a problem with the vtype daterange. When I create only one panel with a dateStart and dateEnd. It's work fine but if I create two or more, I've the error too much recursion.

Here is my code in my UI code:


GraphiquePanelUi = Ext.extend(Ext.Panel, {
title: '',
height: 300,
layout: 'fit',
initComponent: function() {
var startdtid = Ext.id();
var enddtid = Ext.id();

this.items = [
{
xtype: 'container',
layout: 'fit',
ref: 'graphPanel'
},
{
xtype: 'hidden',
name: 'PANEL_ID',
ref: 'PANEL_ID'
}
];
this.tbar = {
xtype: 'toolbar',
items: [
{
xtype: 'datefield',
emptyText: 'Début',
width: 80,
id: startdtid,
vtype: 'daterange',
editable: false,
ref: '../dateStart',
endDateField: enddtid
},
{
xtype: 'tbseparator'
},
{
xtype: 'datefield',
width: 80,
emptyText: 'Fin',
vtype: 'daterange',
editable: false,
id: enddtid,
ref: '../dateEnd',
startDateField: startdtid
},
{
xtype: 'tbfill'
},
{
xtype: 'combo',
store: 'PasStore',
editable: false,
emptyText: 'Sélectionnez un pas de temps',
displayField: 'Name',
valueField: 'Name',
forceSelection: true,
mode: 'local',
triggerAction: 'all',
allowBlank: false,
hiddenName: 'Pas',
submitValue: true,
ref: '../comboPas'
}
]
};
GraphiquePanelUi.superclass.initComponent.call(this);
}
});


Here is the code in the vType (provide from Sencha website : http://dev.sencha.com/deploy/dev/examples/form/adv-vtypes.html)

Do you have any idea where the problem can come from ?

Thank you.

Condor
1 Nov 2010, 2:55 AM
And you are generating new a startdtid and enddtid every time?

kyrillos52
1 Nov 2010, 5:43 AM
When I write an alert of startdtid and enddtid, I've a different in each panel I create.

Condor
1 Nov 2010, 5:53 AM
Well, I don't see anything else that could be wrong.

The only thing left is debugging. Put a breakpoint in the Ext.form.VTypes.daterange function and see why it creates an infinite loop.

kyrillos52
1 Nov 2010, 7:30 AM
Well, I don't see anything else that could be wrong.

The only thing left is debugging. Put a breakpoint in the Ext.form.VTypes.daterange function and see why it creates an infinite loop.

The problem can come from this.dateRangeMax ? I think he loop because of this.



if(!date){
return false;
}
if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
var start = Ext.getCmp(field.startDateField);
start.setMaxValue(date);
start.validate();
this.dateRangeMax = date;
}
else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
var end = Ext.getCmp(field.endDateField);
end.setMinValue(date);
end.validate();
this.dateRangeMin = date;
}
/*
* Always return true since we're only using this vtype to set the
* min/max allowed values (these are tested for after the vtype test)
*/
return true;


I think that a modification is needed in this code if they are some panels with this field.startDateField

Condor
1 Nov 2010, 7:53 AM
Yes, dateRangeMax and dateRangeMin shouldn't be stored in 'this'.

Try replacing it with:

if (field.startDateField) {
var start = Ext.getCmp(field.startDateField);
if (!start.maxValue || (date.getTime() != start.maxValue.getTime())) {
start.setMaxValue(date);
start.validate();
}
}
else if (field.endDateField) {
var end = Ext.getCmp(field.endDateField);
if (!end.minValue || (date.getTime() != end.minValue.getTime())) {
end.setMinValue(date);
end.validate();
}
}
Disclaimer: Completely untested code!

kyrillos52
3 Nov 2010, 6:57 AM
Yes, It's work, thank you

Condor
3 Nov 2010, 7:07 AM
Moving this to the Bugs section.

This should be fixed, even if it is only example code.

meroy
11 Nov 2010, 8:27 PM
This has been fixed in SVN for 3.3.x.