HI!
STORE:
ISSUE: we still need a store like this?
VIEWMODEL:
C) or is there a more correct way? Which One?
Store, Model, ViewModel: what's the correct way?
I have some doubts with extjs 5.1.0
What is the correct way to use store, model and viewmodel
A) this one:
Model:
Code:
Ext.define('App.model.MyModel', {
extend: 'Ext.data.Model',
fields: ['id', 'name', 'email', 'address'],
proxy: {
type: 'ajax',
api: {
create : '/contacts/create',
read : '/contacts/read',
update : '/contacts/update',
destroy : '/contacts/destroy'
},
reader: {
type: 'json',
rootProperty: 'contacts',
totalProperty: 'total'
}
}
});
STORE:
ISSUE: we still need a store like this?
Code:
Ext.define('App.store.MyStore', {
extend: 'Ext.data.Store',
alias: 'store.mystore',
config: {
model: 'App.model.MyModel'
}
});
VIEWMODEL:
Code:
Ext.define('App.view.model.MyViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.myviewmodel',
stores: {
contacts: {
type: 'mystore',
autoLoad: {
page: 1,
start: 0,
limit: 10
},
pageSize: 10
}
}
});
B ) or can do so only:
VIEWMODEL:
Code:
Ext.define('App.view.model.MyViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.myviewmodel',
stores: {
contacts: {
type: 'mystore',
fields: ['id', 'name', 'email', 'address'],
autoLoad: {
page: 1,
start: 0,
limit: 10
},
pageSize: 10,
proxy: {
type: 'ajax',
api: {
create : '/contacts/create',
read : '/contacts/read',
update : '/contacts/update',
destroy : '/contacts/destroy'
},
reader: {
type: 'json',
rootProperty: 'contacts',
totalProperty: 'total'
}
}
}
}
});
C) or is there a more correct way? Which One?
Thanks in advance.
Store, Model, ViewModel: what's the correct way?
Aucun commentaire:
Enregistrer un commentaire