[ExtJS5 learning notes] section 20th Extjs5 uses the array push method to dynamically create and load components, and extjs5push

Source: Internet
Author: User

[ExtJS5 learning notes] section 20th Extjs5 uses the array push method to dynamically create and load components, and extjs5push

Address: http://blog.csdn.net/sushengmiyan/article/details/39226773

Official example: http://docs.sencha.com/extjs/5.0/apidocs! /Api/Array-method-push

Author: sushengmiyan

Certificate ------------------------------------------------------------------------------------------------------------------------------------

The previous section shows how to use the fieldset set to manage components. Each component in fieldset is specified in items, as shown below:


As you can see, items is actually an array, which can be seen as an array of json format styles. In this case, after we define such a string style, we can use the push method of the array to load these items one by one to dynamically create components.


First, let's take a look at the effect. fieldset on the right is dynamically created and loaded through the push method of array:

The Code is as follows:


Ext. define ('fieldsettest. view. form. baseForm ', {extend: 'ext. form. panel ', alias: 'widget. baseform ', title: 'formpanel with fieldSet', frame: true, bodyStyle: 'padding: 5px 5px 0', items: [], initComponent: function () {var me = this; var obj = [{// Fieldset in Column 1-collapsible via toggle buttonxtype: 'fieldset', columnWidth: 0.5, title: 'fieldset 1', collapsible: true, defaultType: 'textfield ', defaults: {anchor: '000000'}, layout: 'anchor', items: [{fieldLabel: 'First name', Name: 'first', allowBlank: false}, {fieldLabel: 'Last name', Name: 'last', allowBlank: false}]}, {// Fieldset in Column 1-collapsible via toggle buttonxtype: 'fieldset', columnWidth: 0.5, title: 'fieldset 2', collapsible: true, defaultType: 'textfield ', ults: {anchor: '20140901'}, layout: 'anchor', items: [{fieldLabel: 'First name', Name: 'first', allowBlank: false}, {fieldLabel: 'Last name', Name: 'last', allowBlank: false}]; Ext. each (obj, function (field, indext) {me. items. push (field) ;}); this. callParent (arguments );}});





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.