Dynamic Model Manipulation
I was Googling around for best practices regarding model manipulation, and apparently, in 4.x, you had this function (setField, example here). But in 6.x, this seems to be gone. I
Solution 1:
You could try to dynamically define a model and then call store.setModel()
.
var starkStore = Ext.create('Ext.data.Store', {
model: Ext.data.Model, // only here to suppress warning
});
var starkModel = Ext.define(Ext.getId(), {
extend: 'Ext.data.Model',
fields: ['id', 'first_name', 'last_name']
});
starkStore.setModel(starkModel);
starkStore.getProxy().getReader().setModel(starkModel);
starkStore.loadData([
{ id: 1, first_name: 'Rob', last_name: 'Stark' },
{ id: 2, first_name: 'John', last_name: 'Snow' },
{ id: 3, first_name: 'Rickon', last_name: 'Stark' },
{ id: 4, first_name: 'Bran', last_name: 'Stark' },
]);
Example on jsfiddle
The only issue here is that you need to have unique name for the dynamic model.
Post a Comment for "Dynamic Model Manipulation"