In ExtJS 6.2, how can I programmatically create formulas?
In my viewmodel I added a constructor, where I'm adding formulas trying to follow what it says here https://forum.sencha.com/forum/showthread.php?299121-Add-Formulas-to-ViewModel-dynamically but my formulas seem to be overwriting the already existing formulas in viewmodel. Also the formulas I add don't seem to be working.
constructor: function(config) {
this.callParent(arguments);
const newFormula = {
test: {
bind : { bindTo : '{mystore}' },
get : mystore => mystore.findExact('type', 'something') !== -1
}
};
this.setFormulas( {...this.getFormulas(), ...newFormula} );
}
Using this way the new formulas work along with the already defined ones, but calling viewmodel getFormulas()
does not list the formula that existed before, only the ones added in config
on constructor.
constructor: function(config) {
config.formulas = config.formulas || {};
config.formulas.test = {
bind : { bindTo : '{mystore}' },
get : mystore => mystore.findExact('type', 'something') !== -1
};
this.callParent(arguments);
}
Getting the already existing formulas and merging into config make it work:
constructor: function(config) {
config.formulas = {...config.formulas, ...this.config.formulas};
config.formulas.test = {
bind : { bindTo : '{mystore}' },
get : mystore => mystore.findExact('type', 'something') !== -1
};
this.callParent(arguments);
}