| Authors: | Dustin Machi |
|---|---|
| Developers: | Dustin Machi |
| since: | V1.0 to 1.3, Removed in 1.4 |
Contents
Note: This API was removed for the Dojo 1.4 release. http://svn.dojotoolkit.org/dojoc/dmachi/data/ contains a JsonStore that is the most suitable replacement for this in Dojo 1.4 and 1.5.
A local (in memory) store which can attach a dojo.data interface to each JavaScript object and uses jsonPath as the query language. It takes an arbitrary JavaScript object as its data structure and attaches to this data structure to present a dojo.data.api interface. Each JavaScript object in the store is an Item in dojo.data parlance.
JsonPathStore is intended to allow any Object data structure to easily be accessed and controlled by various widgets. It uses JsonPath as a query language. It is a very lightweight server, yet it is flexible enough to allow you to define a single store maintaining several unrelated data sets in a single store. Furthermore, it implements a synchronous mode which makes manipulation of the store possible when appropriate for an application.
release also includes experimental synchronous API.
All async features remain the same, but since data is local, custom widgets and code can take advantage of these features while still allowing other normal widgets async access. See the mode property in the constructor parameters
In addition to the standard store api, the store provides a few additional methods of note:
setData(data)
Set the store's data to the supplied object and then load or setup that data with the required meta info.
cleanMeta(data)
Recurse through the provided data object and remove any meta information that has attached. This method also removes any IDs that were auto generated. IDs provided to the store will not be touched.
dump(options)
Takes a options keyword parameter accepting clone, cleanMeta, and suppressExportMeta Boolean options and an export type option that takes "raw" or "json" as the parameters.
Two additional notification events are also triggered in this store, onSave() and onRevert() which will each be called after their respective events have completed.
var store = new dojox.data.jsonPathStore({url: "/stores/store.js"});
var store = new dojox.data.jsonPathStore({data: {
fruits: [
{id: 1, type: apple},
{id: 2, type: orange}
],
vegetables: [
{id: 3, type: "broccoli"}
]
});
The jsonPathStore takes a single optional parameter in the form of a JavaScript object containing one or more of the following properties:
var store = new dojox.data.jsonPathStore({data: {
fruits: [
{id: 1, type: apple},
{id: 2, type: orange}
],
vegetables: [
{id: 3, type: "broccoli"}
]
});
<div data-dojo-id="store" data-dojo-type="dojox.data.jsonPathStore" data-dojo-props="url:'/path/to/store.js'"></div>