View models and bindings for extjs

deep binding
 
myinfo: {
    autoLoad:true,
    model:'EPMMS.model.Memberinfo',
    proxy: {
        type:'ajax',
        url : 'start/index',
        extraParams:{my:true},
        reader: {
            type: 'json',
            rootProperty: 'memberinfo'
        }
    },
}

formulas:{
    info:{
        bind:{bindTo:'{myinfo}',deep:true},//Explicit binding + deep binding
        get:function(store){
            return store.first();
        }
    }
}
 
 
 
Using the deep:tree option, when the content specified by the bindTo option changes, the get calculation is triggered. Otherwise, the get calculation is triggered only when the object reference changes. If the value of myinfo is dynamically obtained, it must be read in this way. get the value.
show binding
The get method passes parameters through the callback function and bindTo, instead of Extjs detecting object references that may be referenced. To use deep binding, you must use explicit binding
 
model binding
links:{ theUser:{ type:'User', id:17}},
 
The id is the id of the model, extjs will automatically initiate a request, and the model needs to be configured with proxy options
Release the properties of the model directly into the viewModel, you can directly access the property name, you can also access the User object
 
record binding
Ext.create('Ext.Component',{ bind:{ data:{ reference:'User', id:42}}});
 
associated record binding
Similar to a record bind, one can also bind to an association, say the User's Address record:
Ext.create('Ext.Component',{ bind:{ data:{ reference:'User', id:42, association:'address'}}});

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326449453&siteId=291194637