PDA

View Full Version : Ext.menu.DateMenu equalent



oe.elvik
25 Feb 2011, 2:54 AM
I want a datemenu to drop down from a button button click, in extjs 3 I used Ext.menu.DateMenu is there somethin similar in extjs 4. I tryed using Ext.picker.Date, but was unable to use it directly as a menu for the button.

Any suggestions?

Animal
25 Feb 2011, 10:13 AM
Yes, Ext.picker.Date, although floatable (as all Components are in Ext 4) is lacking the "showBy" method.

In fact, this should be hoisted into the Component class in 4.0 because Components may be configured floating: true

I'll fix that.

In the meantime, you can borrow the method. configure your Button with



menu: new Ext.picker.Date({
floating: true,
showBy: Ext.menu.Menu.prototype.showBy
})


And ensure you are using ext-all(-debug).js because there's a bug in Ext.date.Picker's definition: it won't inherit day names and month names correctly.

I'll fix all these things for the next release.

Animal
25 Feb 2011, 11:52 AM
Actually, that will pop up the DatePicker, but that won't then disappear if you click outside of it.

The correct solution is



menu: {
border: false,
items: new Ext.picker.Date()
}


The missing border on the DatePicker has been fixed here ready for next release.

oe.elvik
28 Feb 2011, 11:28 PM
I tried your code, but get this error: item.on is not a function
Tried to remove the param items, but stil got the error, so the problem must be the menu object

Animal
1 Mar 2011, 8:59 AM
This:



{
text: 'Date',
menu: {
border: false,
items: {
xtype: 'datepicker'
}
}
}


Gives this for me

http://cl.ly/4vdD/Screen_shot_2011-03-01_at_08.58.26.png

oe.elvik
1 Mar 2011, 10:00 AM
oh, just found out, i didnt call parent initComponent after setting the menu in initComponent

Now it works