Home >Web Front-end >JS Tutorial >Detailed explanation of the case of taking value and text from extjs3 combobox_extjs

Detailed explanation of the case of taking value and text from extjs3 combobox_extjs

WBOY
WBOYOriginal
2016-05-16 17:41:551432browse


When using combobox, it has a hiddenName attribute, which is specially used to submit the value of the value in the combobox.
Now assume that the Id of a combobox is comboId, and the value of the hiddenName attribute is hiddenValue,
Then, what you use the Ext.get('comboId').dom.value method to get is the text value of the selected item in the combobox,
and what you use Ext.get('hiddenValue').dom.value is. It is the value that needs to be submitted in the combobox.
Ext.getCmp("ID value").getValue(); What is obtained is the Value value
.replace(/s/g, ""); //Remove all line breaks and spaces in the json text , tab;
============================================
Extjs executes the click event of the button and the handler event
The easiest way is to look at the html code dom generated by extjs and find the corresponding generated ID
For example:
Method 1:

Copy code The code is as follows:

var btn = document.getElementById("ext-gen40");/ /The ext-gen40 here is the iD generated by extjs. But sometimes this id will change,
btn.click();

Method 2:
Copy code The code is as follows:

Ext.getCmp('title2d').fireEvent("click"); //here "title2d" is the id in the extjs code

Execute button handler event:
Copy code Code 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(-click-)-on-buttons-don-t-call-handler-function
onClick is a method , and handler is a configuration item
The difference between extjs onclick and handler: http://blog.csdn.net/21aspnet/article/details/6865571
============= ======================================= Get the value of the text box
1 , Html text box
such as:
Copy code The code is as follows:



The way to get the value is:
Copy code The code is as follows:

var tValue = Ext.getDom('test').value;

or
Copy code The code is as follows:

var tValue = document.getElementById('test').value

2. ExtJs components
such as:
Copy code The code is as follows:

{
id:'test',
xtype:'textfield',
fieldLabel:' test',
name:'test',
width:370
}

The way to get the value is:
Copy the code The code is as follows:

var tValue = Ext.getCmp('test').getValue();
 Ext.get('test').dom.value

Set the value of the text box
Copy code The code is as follows:

Ext.getCmp('test').setValue("set value ");

================================ Enabling and disabling buttons
Copy code The code is as follows:

Ext.getCmp('btnQc').disable();// Disable
Ext.getCmp('btnQc').enable();//Enable

Method 1: You can directly add attributes when defining the button of bbar. The hidden : true attribute can be hidden; the disabled : true attribute can be disabled. Method 2: Add an id to the button, such as id:'btn'; then in the panel Call Ext.getCmp('btn').disable(); to disable or Ext.getCmp('btn').enable(); to enable in the event. Ext.getCmp('btn').setVisible (false); hide or Ext.getCmp('btn').setVisible (true); display.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn