Misunderstandings about how to add child components in ext JS

Source: Internet
Author: User

Some people often ask me why my grid cannot be automatically adjusted as the age window changes. After learning about this, I found that many people are used to rendering gird into a DIV in the container when rendering child components, which is exactly the problem.

In the Layout System of ext JS, the sub-components of the container can be controlled. For the grid rendered to a DIV in the container, it does not know that a grid is added to the container. When the size is adjusted, the grid size cannot be adjusted, this is why the grid will not change as the container changes.

Why do so many people like to use this method to add child components?I think there are two main reasons:
1. I do not know how to add sub-components to the container,
2. I am used to developing methods using other frameworks such as jquery, which cannot be changed at the moment.

The first reason is that as long as the grid is dynamically added, many beginners are helpless. For example, my grid needs to be remotely returned before knowing how to create it, how can I add the script to the container? I have also made such a mistake in ext Js. Therefore, the role of this article is to solve the problem.

There are two methods:First, use ajax to load the entire grid (or other component configuration objects) to the local device, and then use the add method of the container to add the component to the container; first, directly use the container load function to directly load and render sub-components. The returned data is the configuration object of the sub-component.

The second reason is getting used to the problem. You can only correct it by yourself. You can get familiar with the ext JS development mode as soon as possible and can easily get rid of this habit.

If you use the MVC of ext JS 4 for development, there will be no such embarrassing situation. Therefore, you can make sub-components into a view, add the view to the container in the controller.

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.