[ExtJS5 Study Notes] section 20th EXTJS5 to dynamically create and load components with the push method of an array

Source: Internet
Author: User

This address: http://blog.csdn.net/sushengmiyan/article/details/39226773

Official Example: Http://docs.sencha.com/extjs/5.0/apidocs/#!/api/Array-method-push

This article Sushengmiyan

--------------------------------------------------------------------------------------------------------------- ---------------------

The previous section saw how to use the FieldSet collection to manage components, where each component in FieldSet is specified in items, as follows:


As you can see, items are actually an array, which can be seen as an array of JSON format styles. In that case, after we have defined such a string style, we can use the push method of the array to load the items into one, and you can create the components dynamically.


Look at the effect first, the fieldset on the right is created dynamically and is loaded by the push method of the array:

The code is as follows:


Ext.define (' Fieldsettest.view.form.BaseForm ', {extend: ' Ext.form.Panel ', alias: ' Widget.baseform ', title: ' With fi  Eldset Formpanel ', 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: ' Field Set 1 ', Collapsible:true,defaulttype: ' TextField ', defaults: {anchor: ' 100% '},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 ', defaults: {anchor: ' 100% '},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);} });


[ExtJS5 Study Notes] section 20th EXTJS5 to dynamically create and load components with the push method of an array

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.