dojox/data/QueryReadStore (version 1.10)

Summary

This class provides a store that is mainly intended to be used for loading data dynamically from the server, used i.e. for retrieving chunks of data from huge data stores on the server (by server-side filtering!). Upon calling the fetch() method of this store the data are requested from the server if they are not yet loaded for paging (or cached).

For example used for a combobox which works on lots of data. It can be used to retrieve the data partially upon entering the letters "ac" it returns only items like "action", "acting", etc.

note: The field name "id" in a query is reserved for looking up data by id. This is necessary as before the first fetch, the store has no way of knowing which field the server will declare as identifier.

Usage

var foo = new QueryReadStore(params);
dojox/data/QueryReadStore
Parameter Type Description
params Object

See the dojox/data/QueryReadStore reference documentation for more information.

Examples

Example 1

// The parameter "query" contains the data that are sent to the server.
var store = new dojox.data.QueryReadStore({url:'/search.php'});
store.fetch({query:{name:'a'}, queryOptions:{ignoreCase:false}});


// Since "serverQuery" is given, it overrules and those data are
// sent to the server.
var store = new dojox.data.QueryReadStore({url:'/search.php'});
store.fetch({serverQuery:{name:'a'}, queryOptions:{ignoreCase:false}});


<div dojoType="dojox.data.QueryReadStore"
    jsId="store2"
    url="../tests/stores/QueryReadStore.php"
    requestMethod="post"></div>
<div dojoType="dojox.grid.data.DojoData"
    jsId="model2"
    store="store2"
    sortFields="[{attribute: 'name', descending: true}]"
    rowsPerPage="30"></div>
<div dojoType="dojox.Grid" id="grid2"
    model="model2"
    structure="gridLayout"
    style="height:300px; width:800px;"></div>

Property Summary

Method Summary

  • _assertIsAttribute(attribute) This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.
  • _assertIsItem(item) It throws an error if item is not valid, so you can call it in every method that needs to throw an error when item is invalid.
  • _fetchItems(request,fetchHandler,errorHandler) The request contains the data as defined in the Read-API.
  • _filterResponse(data) If the data from servers needs to be processed before it can be processed by this store, then this function should be re-implemented in subclass.
  • _xhrFetchHandler(data,request,fetchHandler,errorHandler)
  • close(request)
  • containsValue(item,attribute,value)
  • fetch(request) See dojo.data.util.simpleFetch.fetch() this is just a copy and I adjusted only the paging, since it happens on the server if doClientPaging is false, thx to http://trac.dojotoolkit.org/ticket/4761 reporting this.
  • fetchItemByIdentity(keywordArgs) See dojo/data/api/Identity.fetchItemByIdentity()
  • getAttributes(item)
  • getFeatures()
  • getIdentity(item) See dojo/data/api/Identity.getIdentity()
  • getIdentityAttributes(item) See dojo/data/api/Identity.getIdentityAttributes()
  • getLabel(item) See dojo/data/api/Read.getLabel()
  • getLabelAttributes(item) See dojo/data/api/Read.getLabelAttributes()
  • getValue(item,attribute,defaultValue)
  • getValues(item,attribute)
  • hasAttribute(item,attribute) See dojo/data/api/Read.hasAttribute()
  • isItem(something)
  • isItemLoaded(something)
  • loadItem(args)

Properties

_className
_features
_identifier
_items
_itemsByIdentity
_labelAttr
_lastServerQuery
_numRows
doClientPaging

By default every request for paging is sent to the server.

doClientSorting

By default all the sorting is done serverside before the data is returned which is the proper place to be doing it for really large datasets.

lastRequestHash
requestMethod
url

Methods

_assertIsAttribute(attribute)

This function tests whether the item passed in is indeed a valid 'attribute' like type for the store.

Parameter Type Description
attribute attribute-name-string

The attribute to test for being contained by the store.

_assertIsItem(item)

It throws an error if item is not valid, so you can call it in every method that needs to throw an error when item is invalid.

Parameter Type Description
item item

The item to test for being contained by the store.

_fetchItems(request,fetchHandler,errorHandler)

The request contains the data as defined in the Read-API. Additionally there is following keyword "serverQuery".

The serverQuery parameter, optional.

This parameter contains the data that will be sent to the server. If this parameter is not given the parameter "query"'s data are sent to the server. This is done for some reasons:

  • to specify explicitly which data are sent to the server, they might also be a mix of what is contained in "query", "queryOptions" and the paging parameters "start" and "count" or may be even completely different things.
  • don't modify the request.query data, so the interface using this store can rely on unmodified data, as the combobox dijit currently does it, it compares if the query has changed
  • request.query is required by the Read-API

I.e. the following examples might be sent via GET:

fetch({query:{name:"abc"}, queryOptions:{ignoreCase:true}})

the URL will become: /url.php?name=abc

fetch({serverQuery:{q:"abc", c:true}, query:{name:"abc"}, queryOptions:{ignoreCase:true}})

the URL will become: /url.php?q=abc&c=true

// The serverQuery-parameter has overruled the query-parameter
// but the query parameter stays untouched, but is not sent to the server!
// The serverQuery contains more data than the query, so they might differ!
Parameter Type Description
request undefined
fetchHandler undefined
errorHandler undefined
_filterResponse(data)

If the data from servers needs to be processed before it can be processed by this store, then this function should be re-implemented in subclass. This default implementation just return the data unchanged.

Parameter Type Description
data undefined

The data received from server

Returns:undefined

The data received from server

_xhrFetchHandler(data,request,fetchHandler,errorHandler)
Parameter Type Description
data undefined
request undefined
fetchHandler undefined
errorHandler undefined
close(request)
Parameter Type Description
request dojo/data/api/Request | Object
Optional
containsValue(item,attribute,value)
Parameter Type Description
item item
attribute attribute-name-string
value anything
Returns:boolean
fetch(request)

See dojo.data.util.simpleFetch.fetch() this is just a copy and I adjusted only the paging, since it happens on the server if doClientPaging is false, thx to http://trac.dojotoolkit.org/ticket/4761 reporting this. Would be nice to be able to use simpleFetch() to reduce copied code, but i dont know how yet. Ideas please!

Parameter Type Description
request Object
Optional
Returns:string
fetchItemByIdentity(keywordArgs)

See dojo/data/api/Identity.fetchItemByIdentity()

Parameter Type Description
keywordArgs Object
getAttributes(item)
Parameter Type Description
item item
Returns:Array
getFeatures()
Returns:undefined
getIdentity(item)

See dojo/data/api/Identity.getIdentity()

Parameter Type Description
item item
Returns:undefined
getIdentityAttributes(item)

See dojo/data/api/Identity.getIdentityAttributes()

Parameter Type Description
item item
Returns:Array
getLabel(item)

See dojo/data/api/Read.getLabel()

Parameter Type Description
item item
Returns:undefined | function
getLabelAttributes(item)

See dojo/data/api/Read.getLabelAttributes()

Parameter Type Description
item item
Returns:Array | null
getValue(item,attribute,defaultValue)
Parameter Type Description
item item
attribute attribute-name-string
defaultValue value
Optional
Returns:value | undefined
getValues(item,attribute)
Parameter Type Description
item item
attribute attribute-name-string
Returns:Array
hasAttribute(item,attribute)

See dojo/data/api/Read.hasAttribute()

Parameter Type Description
item item
attribute attribute-name-string
Returns:undefined
isItem(something)
Parameter Type Description
something anything
Returns:boolean
isItemLoaded(something)
Parameter Type Description
something anything
Returns:undefined
loadItem(args)
Parameter Type Description
args object
Error in the documentation? Can’t find what you are looking for? Let us know!