[ExtJS5 Study Notes] section 16th use the ViewModel attribute added by panel to bind data to Extjs5

Source: Internet
Author: User

[ExtJS5 Study Notes] section 16th use the ViewModel attribute added by panel to bind data to Extjs5

 

 

In versions earlier than Sencha ext js 5, the concept of viewmodel was not used. Now that extjs5 supports the mvvm mode, her components also add default support for mvvm. Now let's take a look at the frequently-used panel component's powerful support for the mvvm mode.

First, let's take a look at the document's definition of the panel's viewmodel attribute:

 

viewModel : String/Object/Ext.app.ViewModelThe ViewModel is a data provider for this component and its children. The data contained in the ViewModel is typically used by adding bind configs to the components that want present or edit this data.When set, the ViewModel is created and links to any inherited viewModel instance from an ancestor container as the parent. The ViewModel hierarchy, once established, only supports creation or destruction of children. The parent of a ViewModel cannot be changed on the fly.If this is a root-level ViewModel, the data model connection is made to this component's associated Data Session. This is determined by calling getInheritedSession.Defaults to: {$value: null, lazy: true}
Translate the above information as follows:

 

ViewModel: the attribute can be set as a String, an Object, or Ext. app. ViewModel.

ViewModel is the data provider of this component and sub-component. A typical usage of the data contained in ViewModel is to add the bind configuration to the component for rendering or editing data.

After the settings are complete, viewmodel creates and connects to any parent component at the inheritance level. Once created, the parent component cannot be changed.

If the root viewmodel is used, datamodel is associated with the data node, which is determined by obtaining the inherited node.

Default: {$ value: null, lazy: true}

 

To put it simply, when you want to obtain data from other models in panle, you need to create a viewmodel. This allows you to obtain data from viewmodel.
 

 

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.