O'Reilly logo

Learning Ext JS 4 by Armando Gonzalez, Crysfel Villa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding menus

There are times when we need to create a menu to allow the user to choose from the available options. We can achieve this by setting the menu property of the buttons. This will create a floating menu for the selected button that will be shown when the user clicks the button.

Let's create a button that contains a menu of options. For the following example we need to create an HTML page, import the Ext JS library, and listen for the DOM ready event. Inside the callback we should write the following code that creates our button with three options:

varbtn1 = Ext.create("Ext.button.Button",{
text: 'Payment',
scale: 'large',
iconCls: 'card-icon32',
renderTo: Ext.getBody(),
menu: [{
text: 'Master Card'
},{
text: 'Visa'
},{
text: 'American ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required