note that dojox.rpc.Service is not required, you can create your own services A ServiceStore is a readonly data store that provides a data.data interface to an RPC service.
var myServices = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.tests.resources", "test.smd")); var serviceStore = new dojox.data.ServiceStore({service:myServices.ServiceStore});
The ServiceStore also supports lazy loading. References can be made to objects that have not been loaded. For example if a service returned:
{"name":"Example","lazyLoadedObject":{"$ref":"obj2"}}
And this object has accessed using the dojo.data API:
var obj = serviceStore.getValue(myObject,"lazyLoadedObject");
The object would automatically be requested from the server (with an object id of "obj2").
ServiceStore can do client side caching and result set updating if dojox.data.ClientFilter is loaded. Do this add:
dojo.require("dojox.data.ClientFilter")
prior to loading the ServiceStore (ClientFilter must be loaded before ServiceStore).
To utilize client side filtering with a subclass, you can break queries into client side and server side components by putting client side actions in clientFilter property in fetch calls. For example you could override fetch:
fetch: function(args){ // do the sorting and paging on the client side args.clientFilter = {start:args.start, count: args.count, sort: args.sort}; // args.query will be passed to the service object for the server side handling return this.inherited(arguments); }
When extending this class, if you would like to create lazy objects, you can follow
the example from dojox.data.tests.stores.ServiceStore:
var lazyItem = { _loadObject: function(callback){ this.name="loaded"; delete this._loadObject; callback(this); } };>ServiceStore can do client side caching and result set updating if dojox.data.ClientFilter is loaded. Do this add:
dojo.require("dojox.data.ClientFilter")
prior to loading the ServiceStore (ClientFilter must be loaded before ServiceStore).
To utilize client side filtering with a subclass, you can break queries into client side and server side components by putting client side actions in clientFilter property in fetch calls. For example you could override fetch:
fetch: function(args){ // do the sorting and paging on the client side args.clientFilter = {start:args.start, count: args.count, sort: args.sort}; // args.query will be passed to the service object for the server side handling return this.inherited(arguments); }
When extending this class, if you would like to create lazy objects, you can follow
the example from dojox.data.tests.stores.ServiceStore:
var lazyItem = { _loadObject: function(callback){ this.name="loaded"; delete this._loadObject; callback(this); } };>
Parameter | Type | Description |
---|---|---|
options | undefined | Keyword arguments The schema parameterThis is a schema object for this store. This should be JSON Schema format. The service parameterThis is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded The idAttribute parameterDefaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index. The estimateCountFactor parameterThis parameter is used by the ServiceStore to estimate the total count. When paging is indicated in a fetch and the response includes the full number of items requested by the fetch's count parameter, then the total count will be estimated to be estimateCountFactor multiplied by the provided count. If this is 1, then it is assumed that the server does not support paging, and the response is the full set of items, where the total count is equal to the number of items returned. If the server does support paging, an estimateCountFactor of 2 is a good value for estimating the total count It is also possible to override _processResults if the server can provide an exact total count. The syncMode parameterSetting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary. This will only work with a synchronous capable service. |
See the dojox/data/ServiceStore reference documentation for more information.
This parameter is used by the ServiceStore to estimate the total count. When paging is indicated in a fetch and the response includes the full number of items requested by the fetch's count parameter, then the total count will be estimated to be estimateCountFactor multiplied by the provided count. If this is 1, then it is assumed that the server does not support paging, and the response is the full set of items, where the total count is equal to the numer of items returned. If the server does support paging, an estimateCountFactor of 2 is a good value for estimating the total count It is also possible to override _processResults if the server can provide an exact total count.
Defaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index.
This is a schema object for this store. This should be JSON Schema format.
This is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded
Setting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary. This will only work with a synchronous capable service.
Parameter | Type | Description |
---|---|---|
results | undefined | |
deferred | undefined |
Checks to see if 'item' has 'value' at 'attribute'
Parameter | Type | Description |
---|---|---|
item | Object | |
attribute | String | |
value | Anything |
See dojo/data/api/Read.fetch
Parameter | Type | Description |
---|---|---|
args | undefined | The queryOptions.cache parameterIf true, indicates that the query result should be cached for future use. This is only available if dojox.data.ClientFilter has been loaded before the ServiceStore The syncMode parameterIndicates that the call should be fetch synchronously if possible (this is not always possible) The clientFetch parameterThis is a fetch keyword argument for explicitly doing client side filtering, querying, and paging |
fetch an item by its identity, by looking in our index of what we have loaded
Parameter | Type | Description |
---|---|---|
args | undefined |
Gets the available attributes of an item's 'property' and returns it as an array.
Parameter | Type | Description |
---|---|---|
item | Object |
returns the attributes which are used to make up the identity of an item. Basically returns this.idAttribute
Parameter | Type | Description |
---|---|---|
item | undefined |
returns the label for an item. Just gets the "label" attribute.
Parameter | Type | Description |
---|---|---|
item | undefined |
returns an array of attributes that are used to create the label of an item
Parameter | Type | Description |
---|---|---|
item | undefined |
Returns a reference to the JSON Schema
Gets the value of an item's 'property'
Parameter | Type | Description |
---|---|---|
item | Object | The item to get the value from |
property | String | property to look up value for |
defaultValue | value |
Optional the default value |
Gets the value of an item's 'property' and returns it. If this value is an array it is just returned, if not, the value is added to an array and that is returned.
Parameter | Type | Description |
---|---|---|
item | Object | |
property | String | property to look up value for |
Checks to see if item has attribute
Parameter | Type | Description |
---|---|---|
item | Object | |
attribute | String |
Checks to see if the argument is an item
Parameter | Type | Description |
---|---|---|
item | Object |
Checks to see if the item is loaded.
Parameter | Type | Description |
---|---|---|
item | object |
Loads an item and calls the callback handler. Note, that this will call the callback handler even if the item is loaded. Consequently, you can use loadItem to ensure that an item is loaded is situations when the item may or may not be loaded yet. If you access a value directly through property access, you can use this to load a lazy value as well (doesn't need to be an item).
Parameter | Type | Description |
---|---|---|
args | undefined |
store.loadItem({ item: item, // this item may or may not be loaded onItem: function(item){ // do something with the item } });