Use extjs3 ComboBox to get value and text

Source: Internet
Author: User

When ComboBox is used, it has a hiddenname attribute, which is used to submit the value of value in ComboBox.

Assume that the ID of a ComboBox is comboid, and the value of the hiddenname attribute is hiddenvalue,

So,

UseExt. Get ('comboid'). Dom. ValueThe method obtains the text of the selected items in ComboBox.TextValue,

Ext. getcmp ("ID value"). getvalue (); Obtained isValueValue

 

. Replace (// \ s/g, ""); // remove all line breaks, spaces, and tabs in JSON text;

========================================================== =

Extjs executes the button click event and the handler event.

The simplest way is to view the HTML code Dom generated by extjs and find the corresponding generated ID

For example:

Method 1:VaR BTN = Document. getelementbyid ("ext-gen40"); // The ext-gen40 here is the ID that extjs generates immediately, but sometimes this ID will change,
BTN. Click ();

Method 2:Ext. getcmp ('title2d '). fireevent ("click"); // here, "title2d" is the ID in extjs code.

Execute the button handler event:

VaR btn2d = ext. getcmp ("title2d ");
Btn2d. handler. Call (btn2d. Scope, btn2d );

Reference URL: http://www.sencha.com/forum/showthread.php? 25677-2.0.1-fireevent % 28-click-% 29-on-buttons-don-t-call-handler-function

Onclick is a method, while handler is a configuration item

Differences between extjs onclick and handler: http://blog.csdn.net/21aspnet/article/details/6865571

========================================================== ================ Get the value of the text box

1. HTML text box
For example, <input type = "text" name = "test" id = "test">

The method to obtain the value is:

VaR tvalue = ext. getdom ('test'). value;

Or

VaR tvalue = Document. getelementbyid ('test'). Value

2. extjs Components

Example :{

ID: 'test ',

Xtype: 'textfield ',

Fieldlabel: '& nbsp; test ',

Name: 'test ',

Width: 370

}

The method to obtain the value is:

VaR tvalue =Ext. getcmp ('test'). getvalue ();

  Ext. Get ('test'). Dom. Value

Set the value of the text box

Ext. getcmp ('test'). setvalue ("Set Value ");

============================================ Enable and disable the button

Ext. getcmp ('btnqc '). Disable (); // disable

Ext. getcmp ('btnqc '). Enable (); // enable

Method 1: You can directly give the property when defining the bbar button. The property "hidden: True" can be hidden. The property "Disabled: True" can be disabled.
Method 2: add an ID to the button, for example, ID: 'btn '. Then, call ext in the panel event. getcmp ('btn '). disable (); Disabled or ext. getcmp ('btn '). enable (); enabled. Ext. getcmp ('btn '). setvisible (false); hide or ext. getcmp ('btn'). setvisible (true); display.

 

 

 

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.