Is it possible bind record of Store by Model-Id instead of referring to the index?
The example below works if bind specific index:env:'{environments.data.items.2}'
However, is it possible using Model-Id, as it makes the code maintainable that way.
:
Code:
Ext.define('EnvironmentStore', {
extend: 'Ext.data.Store',
storeId: 'environmentStore',
alias: 'store.environment',
model: 'EnvironmentModel',
proxy: {
type: 'ajax',
url: 'environment',
method: 'GET',
reader: {
type: 'json',
rootProperty: 'root'
}
}
});
Ext.define('EnvironmentModel', {
extend: 'Ext.data.Model',
idProperty: 'variableName',
fields: [
{ name: 'variableName', type: 'string' },
{ name: 'variableValue', type: 'string' }
]
});
Ext.define('EnvironmentVM', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.environment',
stores: {
environments: {
type: 'environment',
autoLoad: true,
session: true
}
},
formulas: {
env: {
bind: {
env: '{environments.data['UAT']}',
deep: true
},
get: function (link) {
if(!link.env) {
return null;
} else { returnlink.env }
}
}
}
});