Extjs4 note (5) Ext. Button button

Source: Internet
Author: User
Back to the series directory

Starting from this article, we will talk about basic controls. extjs has its own set of encapsulation for all UI controls. This article describes the buttons of extjs. It mainly includes button events, buttons with split lines, icons, buttons with menus, drop-down option buttons, and button combinations. Let's take a look:

Preview

The following HTML is used:

[HTML]

 
<H1> events are implemented in three ways:  
I. Basic buttons, three methods to implement button events

The most basic button generation is introduced here.CodeThe first button is in the pop-up and press statuses. Do not set the three buttons to three sizes. The click event of each button is implemented in a new way. Let's take a look at the JS Code:

[JS]

 
Ext. create ("Ext. button ", {renderto: ext. get ("Li1"), text: "event Implementation 1", allowdepress: True, // enabletoggle: True, // whether to allow the handler: function () {Ext. MSG. alert ("prompt", "first event") ;}, ID: "Bt1"}); Ext. create ("Ext. button ", {renderto: ext. get ("li2"), text: "event implementation 2", listeners: {"click": function () {Ext. MSG. alert ("prompt", "second event") ;}, ID: "bt2", scale: 'medium '}); var bt3 = ext. create ("Ext. button ", {renderto: ext. get ("li3 "). dom, text: "event Implementation 3", ID: "bt3", scale: 'large'}); bt3.on ("click", function () {Ext. MSG. alert ("prompt", "third event ");});

2. Menu with icons

Buttons can contain icons and menus. We can configure them in the configuration items:

[JS]

Ext. create ("Ext. button ", {renderto: ext. get ("div2"), ID: "bt4", text: "With menu with icon", iconcls: "add16", menu: {items: [{text: 'option 1'}, {text: 'option 2'}, {text: 'option 3', Handler: function () {Ext. MSG. alert ("prompt", "Message from menu") ;}}]}). showmenu (); Ext. create ("Ext. button ", {renderto: ext. get ("div2"), ID: "BT5", text: "", iconcls: "add16", iconalign: 'top', menu: {items: [{text: 'option 1'}, {text: 'option 2'}, {text: 'option 3', Handler: function () {Ext. MSG. alert ("prompt", "Message from menu") ;}}, arrowalign: 'bottom '});

3. Button with split line

Note: The split line button comes from the Ext. splitbutton class.

[JS]

 
Ext. create ("Ext. button. split ", {renderto: ext. get ("div3"), text: "menu under the right icon", iconcls: "add16", iconalign: 'right', menu: {items: [{text: 'option 1'}, {text: 'option 2'}, {text: 'option 3', Handler: function () {Ext. MSG. alert ("prompt", "Message from menu") ;}}, arrowalign: 'bottom '});

Iv. Menu buttons

Unlike the pull-down menu, the Ext. cyclebutton has the selected status. When the selected drop-down is selected, the selected text changes accordingly.

[JS]

Ext. create ('ext. button. cycle ', {renderto: ext. get ("div4"), showtext: True, prependtext: 'select:', menu: {items: [{text: 'option 1', checked: true }, {text: 'option 2'}, {text: 'option 3'}]}, changehandler: function (BTN, item) {Ext. MSG. alert ('modify select', item. text );}});

4. button combination

Defines a group of buttons and controls button layout.

[JS]

Ext. create ("Ext. buttongroup ", {renderto: ext. get ("div5"), title: "button combination", columns: 3, // defaulttype: 'splitting', items: [{text: 'button 1', iconcls: 'add16', scale: 'large', rowspan: 2}, {text: 'button 2', iconcls: 'add16', rowspan: 2, scale: 'large '}, {text: 'button 3', iconcls: 'add16'}, {xtype: 'splitting', text: 'linecut button ', iconcls: 'add16', menu: [{text: 'menu 1'}]});

By Lipan)
Source: [Lipan] (http://www.cnblogs.com/lipan)
Copyright: The copyright of this article is shared by the author and the blog. The detailed link of this article must be noted during reprinting; otherwise, the author will be held legally liable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.