Constructordojox.data.JsonRestStore

dojo.require("dojox.rpc.JsonRestStore");
defined in dojox/rpc/JsonRestStore.js

JsonRestStore constructor, instantiate a new JsonRestStore A JsonRestStore can be configured from a JSON Schema. Queries are just passed through as URLs for XHR requests, so there is nothing to configure, just plug n play. Of course there are some options to fiddle with if you want: jsonSchema: / object / service: / function / 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 The function should also have the following methods: put(id,value) - puts the value at the given id post(id,value) - posts (appends) the value at the given id delete(id) - deletes the value corresponding to the given id

Usage

function (options) (view source)
parametertypedescription
options  

Jump to PropertiesFunctionsBack to top

FunctioncontainsValue(item: Object, attribute: String, value)
Checks to see if 'item' has 'value' at 'attribute'
FunctiondeleteItem(item, parentInfo: Array)
deletes item any references to that item from the store.
Functionfetch(args)
console.log("fetch() ", args); fetch takes either a string argument or a keywordArgs object containing the parameters for the search. If passed a string, fetch will interpret this string as the query to be performed and will do so in SYNC_MODE returning the results immediately. If an object is supplied as 'args', its options will be parsed and then contained query executed. query: /* string or object */ Defaults to "". This is basically passed to the XHR request as the URL to get the data start: /* int */ Starting item in result set count: /* int */ Maximum number of items to return cache: /* boolean */ sort: /* function */ Not Implemented yet The following only apply to ASYNC requests (the default) onBegin: /* function */ called before any results are returned. Parameters will be the count and the original fetch request onItem: /*function*/ called for each returned item. Parameters will be the item and the fetch request onComplete: /* function */ called on completion of the request. Parameters will be the complete result set and the request onError: /* function */ colled in the event of an error
fetch an item by its identity. fetch and fetchItemByIdentity work exactly the same
Gets the available attributes of an item's 'property' and returns it as an array.
return the store feature set
FunctiongetLabel(item)
FunctiongetValue(item: Object, property, lazyCallback)
Gets the value of an item's 'property'
FunctiongetValues(item: Object, property)
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.
FunctionhasAttribute(item: Object, attribute: String)
Checks to see if item has attribute
FunctionisDirty(item)
FunctionisItem(item: Object)
Checks to see if a passed 'item' is really a JsonRestStore item.
FunctionloadItem(item)
Loads an item that has not been loaded yet. Lazy loading should happen through getValue, and if used properly, this should never need to be called
FunctionnewItem(data: Object, parentInfo)
adds a new item to the store at the specified point. Takes two parameters, data, and options.
notification of the revert event..not part of the notification api, but probably should be.
FunctiononSave(items)
notification of the save event..not part of the notification api, but probably should be. console.log("onSave() ", items);
Functionsave(kwArgs)
Saves the dirty data using REST Ajax methods
FunctionsetValue(item, attribute, value)
sets 'attribute' on 'item' to 'value'
FunctionsetValues(item, attribute, values)
sets 'attribute' on 'item' to 'value' value must be an array.
Functionsort(a, b)
FunctionunsetAttribute(item, attribute)
unsets 'attribute' on 'item'
Function_commitAppend(listId, item)
Function_getParent(parentInfo)
Function_loadById(id, callback)
Function_setDirty(item)
adds an item to the list of dirty items. This item contains a reference to the item itself as well as a cloned and trimmed version of old item for use with revert.
Function_walk(value, forEach)

Jump to FunctionsPropertiesBack to top

*/ 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.