I have the requirement to recalculate a field in a model on a certain event. I want to calculate the value directly in the model, and not in the view renderers, because otherwise multiple views would also need custom sorting and grouping functions, so the code would bloat massively. I could however use convert
instead of calculate
, if that helps.
The fields on the model:
fields: [{
name: 'name',
type: 'string'
},{
name: 'localizedName',
calculate: function(data) {
return Globals.localize(data.name);
}
}]
and the function on the store:
onUILocaleChange: function() {
this.each(function(record) {
// force recalculate
});
}
I have made a fiddle that exhibits the behaviour I wish to achieve, but without the bad hacky workaround: https://fiddle.sencha.com/#view/editor&fiddle/2g7g
I would like this to work without line 73-75, in-place in the model.