O'Reilly logo

Learning Ext JS - Fourth Edition by Armando Gonzalez, Crysfel Villa, Carlos A. Méndez

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 (or menus) 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, and it will be shown when the user clicks on the button.

Let's create a button that contains a menu with 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 modify the code that creates our button, as shown here:

  var myButton = Ext.create('Ext.button.Button',{
    text:'Add payment method...',
    iconCls:'addicon-32',
    iconAlign:'left',
    scale:'large',
    renderTo:'normalbuttons',
    menu:[
 {text:'Master ...

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