EXTJS5 a container has several components that are common to one controller and one model

Source: Internet
Author: User

1Ext.define (' Testviewmodel ', {2Extend: ' Ext.app.ViewModel ',3 4Alias: ' Viewmodel.test ',//connects to Viewmodel/type below5Constructorfunction(config) {6     //Here you can see the model that was instantiated several times7 console.log (config);8      This. callparent (config);9   },Ten  One data: { AFirstName: ' John ', -LastName: ' Doe ' -   }, the  - formulas: { -     //We ' ll explain formulas in more detail soon. -Namefunction(get) { +       varfn = Get (' firstName '), ln = get (' LastName '); -       return(FN && LN)? (fn + ' + ln): (fn | | ln | | ‘‘); +     } A   } at }); -  -Ext.define (' TestView ', { -Extend: ' Ext.panel.Panel ', -Layout: ' Form ', -  in requires: [ -' Testviewmodel ' to   ], +  -   //Always use the this form when defining a view class. this the   //allows the creator of the component to pass data without *   //erasing the ViewModel type that we want. $ ViewModel: {Panax NotoginsengType: ' Test '//references alias "Viewmodel.test" -   }, the  + bind: { ATitle: ' Hello {name} ' the   }, +  -DefaultType: ' TextField ', $ items: [{ $Fieldlabel: ' First Name ', -Bind: ' {firstName} ' -   },{ theFieldlabel: ' Last Name ', - bind:{WuyiValue: ' {lastName} ' the     }  -   },{ WuXtype: ' button ', -Text: ' Submit ', About bind: { $Hidden: ' {!name} ' -     } -   },{ -Xtype: ' Demo ' A   }] + }); the  -Ext.onready (function () { $Ext.create (' TestView ', { the renderTo:Ext.getBody (), thewidth:400 the   }); the }); -  in  theExt.define (' Demo ', { theExtend: ' Ext.panel.Panel ', AboutLayout: ' Form ', theAlias: ' Widget.demo ', the  the requires: [ +' Testviewmodel ' -   ], the   //Always use the this form when defining a view class. thisBayi   //allows the creator of the component to pass data without the   //erasing the ViewModel type that we want. theInitComponent:function(){ -     //THIS.OWNERCT -     //var parent = this.findparentbytype (' panel '); the     //Console.log (parent.title); the  the     varf = This. Getviewmodel (). Get (' FirstName '); the Console.log (f); -      This. Callparent (arguments); the   }, the   //This place is empty, you can use the same model as the main container, if you viewmodel:{type:test}, it is equivalent to the   //Instantiate an example of a model94 ViewModel: { the  the   }, the 98 bind: { AboutTitle: ' {firstName} ' -   }101   102});


/*
When there are several components in a container common to one controller and one model
When using a controller in a component: ' Main ', a container component can be used to share one, when the container is instantiated, that is, a director
However, when you use Viewmodel:type: ' main ' in your component, you need to consider it because each component instantiates a
Model, if you want the container and the component to share a model, an instantiation. Set Viewmodel:{type: ' Main '} in the container, set ViewModel in the component: {}, empty it.
*/

EXTJS5 a container has several components that are common to one controller and one model

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.