Use extjs3 combobox to obtain 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,
Use Ext. get ('comboid'). dom. value to obtain the text value of the selected item in combobox,
The value to be submitted in combobox is obtained using Ext. get ('hiddenvalue'). dom. value.
Ext. getCmp ("ID Value"). getValue (); the Value is obtained.
. 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:

Copy codeThe Code is as follows: 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:Copy codeThe Code is as follows: Ext. getCmp ('title2d '). fireEvent ("click"); // here "title2d" is the id in extjs code

Execute the button handler event:Copy codeThe Code is as follows: 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:Copy codeThe Code is as follows: <input type = "text" name = "test" id = "test">

The method to obtain the value is:Copy codeThe Code is as follows: var tValue = Ext. getDom ('test'). value;

OrCopy codeThe Code is as follows: var tValue = document. getElementById ('test'). value

2. ExtJs Components
For example:Copy codeThe Code is as follows :{
Id: 'test ',
Xtype: 'textfield ',
FieldLabel: 'test ',
Name: 'test ',
Width: 370
}

The method to obtain the value is:Copy codeThe Code is as follows: var tValue = Ext. getCmp ('test'). getValue ();
Ext. get ('test'). dom. value

Set the value of the text boxCopy codeThe Code is as follows: Ext. getCmp ('test'). setValue ("Set Value ");

============================================ Enable and disable the buttonCopy codeThe Code is as follows: 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. 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.