How to use Extjs4 up and down

Source: Internet
Author: User

 usage of up () and down () in Extjs4extjs4.x, each component has a new addition of two method up () and down () methods. Both of these methods are used to get the component, so let's look at the official explanation of the up () method and the Down () method.

In extjs4.x, the new two method up () and down () methods are added. Both of these methods are used to get the components, let's look at the official explanation below.

Up (String selector, [number/mixed maxDepth]): Ext.core.Element

Selector: required, in string form, representing the component to match.

Maxdepth: Optional, indicating the maximum depth to match.

The API for the UP method is interpreted as: with a simple selection, to get the matching DOM, using the UP method always returns a Ext.core.Element, which is the component of Ext.

Down (String selector, [Boolean returndom]): htmlelement/ext.core.element

Selector: required, in string form, representing the component to match,

Returndom: Optional, Boolean type, if True, returns a DOM node instead of Ext.core.Element. The value defaults to False.

The API interpretation of the down method, through selectors, to obtain any sub-component of depth, in the down method, should not contain the ID of the component, but should be the xtype of the component.

Let's take a look at his usage. Look at the code first.

  1. Ext.require (' ext.* ');
  2. Ext.onready (function () {
  3. var win = ext.create (' Ext.window.Window ', {
  4. height:160,
  5. width:280,
  6. Title: ' User login ',
  7. Closeaction: ' hide ',
  8. Closable: false,
  9. Iconcls: ' win ',
  10. Layout: ' fit ',
  11. Modal: true,
  12. Plain: true,
  13. Resizable: false,
  14. items:[{
  15. Xtype:' form ',
  16. items:[{
  17. //..... 
  18. }],
  19. button:[{
  20. Text:' login ',
  21. Handler:function () {
  22. }
  23. }]
  24. }]
  25. })
  26. });
Ext.require (' ext.* '); Ext.onready (function () {  var win = ext.create (' Ext.window.Window ', {   height:160,   width:280,   title: ' User Login ',   closeaction: ' Hide ',   closable:false,    iconcls: ' Win ',   layout: ' Fit ',   modal:true,    Plain:true,   resizable:false,   items:[{    xtype: ' form ',    items:[{     //...     }],    button:[{     text: ' Login ',     handler:function () {           }}]})  });


In this code, we created a window and then added a form to the window. Finally, a button is added. Button's handler, we define a function. Next, we add code to this function.

    1. var form = this.up (' form '). GetForm ();
var form = this.up (' form '). GetForm ();

The this.up is used here. Specifically explained below. Here this. is the button component, and up (' form ') refers to the matching form component. So together, we get the form component, and we get the whole form.

In this case, we don't need the down method. Because either the form or window is acquired. We can use This.up (' form ') or this.up (' window ') to get the form component and the window component.

To introduce the down method. We'll complicate the whole process.

    1. var form = this.up (' window '). Down (' form '). GetForm ();
var form = this.up (' window '). Down (' form '). GetForm ();

I'm sure you understand that this.up (' window ') gets the top-level window component. It then uses the down () method to obtain the sub-component form component of window, and finally uses getform () to obtain the entire form.

Conclusion: In Extjs4, ExtJS adds the up () and down () methods to each component, which makes it easier to get the parent and child components of each component. Of course, in addition to these methods, ExtJS also adds a more powerful Componentquery class, through which we can use more methods to find whatever components are needed. The use of specific componentquery

Thank http://blog.csdn.net/li_xiao_ming/article/details/7063610 for sharing

How to use Extjs4 up and down

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.