Artistan
12 Jan 2012, 7:26 AM
I have noticed a few things dealing with stores and models.
1. JSON Stores default to AjaxProxy, acceptable.
- when you transform the AjaxProxy to a RestProxy, the name stays with MyAjaxProxy1...
- this can be very confusing when working on the stores.
- maybe simply allowing to manually set the "name" of the Proxy, or auto change it based on the type?
2. Defining a store with a model.
- correct me if I am wrong, but can you not define a model with a proxy and then use that model to create multiple stores?
- below is what designer makes.
- below that is what I suggest. (using the Model's Proxy if the store proxy is deleted.)
- this would require allowing to delete proxy/reader from store?
Model.
Ext.define('BenAdmin.model.VisitsSites', {
extend: 'Ext.data.Model',
idProperty: 'vsid',
remoteFilter: true,
remoteSort: true,
proxy: {
type: 'rest',
url: 'http://visits.benint.net/rest/siteshare/visits/site/',
reader: {
type: 'json',
idProperty: 'vsid',
root: 'items',
totalProperty: 'totalCount'
}
},
fields: [
{
name: 'vsid',
type: 'int'
},
{
name: 'sitename',
type: 'string'
},
{
name: 'db',
type: 'string'
}
]
});
Store.
Ext.define('BenAdmin.store.VisitsSites', {
extend: 'BenAdmin.store.base.VisitsSites',
alias: 'widget.store_visits_sites',
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({}, cfg)]);
}
});
Base Store.
Ext.define('BenAdmin.store.base.VisitsSites', {
extend: 'Ext.data.Store',
requires: [
'BenAdmin.model.VisitsSites'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
storeId: 'store_visits_sites',
model: 'BenAdmin.model.VisitsSites',
remoteFilter: true,
remoteSort: true,
proxy: {
type: 'ajax',
url: 'http://visits.benint.net/rest/siteshare/visits/site/',
reader: {
type: 'json',
idProperty: 'vsid',
root: 'items',
totalProperty: 'totalCount'
}
}
}, cfg)]);
}
});
ALTERNATE BASE STORE
Should use the Model's Proxy????
( Currently cannot delete a proxy/reader from a designer store )
Ext.define('BenAdmin.store.base.VisitsSites', {
extend: 'Ext.data.Store',
requires: [
'BenAdmin.model.VisitsSites'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
storeId: 'store_visits_sites',
model: 'BenAdmin.model.VisitsSites',
remoteFilter: true,
remoteSort: true
}, cfg)]);
}
});
FROM THE Model Docs...
Usage in Stores
It is very common to want to load a set of Model instances to be displayed and manipulated in the UI. We do this by creating aStore (http://docs.sencha.com/touch/2-0/#%21/api/Ext.data.Store):
var store =Ext.create (http://docs.sencha.com/touch/2-0/#%21/api/Ext-method-create)('Ext.data.Store (http://docs.sencha.com/touch/2-0/#%21/api/Ext.data.Store)',{ model:'User'});//uses the Proxy we set up on Model to load the Store data store.load();A Store is just a collection of Model instances - usually loaded from a server somewhere. Store can also maintain a set of added, updated and removed Model instances to be synchronized with the server via the Proxy. See the Store docs (http://docs.sencha.com/touch/2-0/#%21/api/Ext.data.Store) for more information on Stores.
1. JSON Stores default to AjaxProxy, acceptable.
- when you transform the AjaxProxy to a RestProxy, the name stays with MyAjaxProxy1...
- this can be very confusing when working on the stores.
- maybe simply allowing to manually set the "name" of the Proxy, or auto change it based on the type?
2. Defining a store with a model.
- correct me if I am wrong, but can you not define a model with a proxy and then use that model to create multiple stores?
- below is what designer makes.
- below that is what I suggest. (using the Model's Proxy if the store proxy is deleted.)
- this would require allowing to delete proxy/reader from store?
Model.
Ext.define('BenAdmin.model.VisitsSites', {
extend: 'Ext.data.Model',
idProperty: 'vsid',
remoteFilter: true,
remoteSort: true,
proxy: {
type: 'rest',
url: 'http://visits.benint.net/rest/siteshare/visits/site/',
reader: {
type: 'json',
idProperty: 'vsid',
root: 'items',
totalProperty: 'totalCount'
}
},
fields: [
{
name: 'vsid',
type: 'int'
},
{
name: 'sitename',
type: 'string'
},
{
name: 'db',
type: 'string'
}
]
});
Store.
Ext.define('BenAdmin.store.VisitsSites', {
extend: 'BenAdmin.store.base.VisitsSites',
alias: 'widget.store_visits_sites',
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({}, cfg)]);
}
});
Base Store.
Ext.define('BenAdmin.store.base.VisitsSites', {
extend: 'Ext.data.Store',
requires: [
'BenAdmin.model.VisitsSites'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
storeId: 'store_visits_sites',
model: 'BenAdmin.model.VisitsSites',
remoteFilter: true,
remoteSort: true,
proxy: {
type: 'ajax',
url: 'http://visits.benint.net/rest/siteshare/visits/site/',
reader: {
type: 'json',
idProperty: 'vsid',
root: 'items',
totalProperty: 'totalCount'
}
}
}, cfg)]);
}
});
ALTERNATE BASE STORE
Should use the Model's Proxy????
( Currently cannot delete a proxy/reader from a designer store )
Ext.define('BenAdmin.store.base.VisitsSites', {
extend: 'Ext.data.Store',
requires: [
'BenAdmin.model.VisitsSites'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
storeId: 'store_visits_sites',
model: 'BenAdmin.model.VisitsSites',
remoteFilter: true,
remoteSort: true
}, cfg)]);
}
});
FROM THE Model Docs...
Usage in Stores
It is very common to want to load a set of Model instances to be displayed and manipulated in the UI. We do this by creating aStore (http://docs.sencha.com/touch/2-0/#%21/api/Ext.data.Store):
var store =Ext.create (http://docs.sencha.com/touch/2-0/#%21/api/Ext-method-create)('Ext.data.Store (http://docs.sencha.com/touch/2-0/#%21/api/Ext.data.Store)',{ model:'User'});//uses the Proxy we set up on Model to load the Store data store.load();A Store is just a collection of Model instances - usually loaded from a server somewhere. Store can also maintain a set of added, updated and removed Model instances to be synchronized with the server via the Proxy. See the Store docs (http://docs.sencha.com/touch/2-0/#%21/api/Ext.data.Store) for more information on Stores.