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 ...

Get Learning Ext JS - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.