dojox.data.CsvStore._fetchItems
dojo.require("dojox.data.CsvStore");
defined in dojox/data/CsvStore.js
See dojo.data.util.simpleFetch.fetch()
Usage
function (/*Object*/ keywordArgs, /*Function*/ findCallback, /*Function*/ errorCallback) (view source)
var self = this; var filter = function(requestArgs, arrayOfAllItems){ var items = null; if(requestArgs.query){ items = []; var ignoreCase = requestArgs.queryOptions ? requestArgs.queryOptions.ignoreCase : false; //See if there are any string values that can be regexp parsed first to avoid multiple regexp gens on the //same value for each item examined. Much more efficient. var regexpList = {}; for(var key in requestArgs.query){ var value = requestArgs.query[key]; if(typeof value === "string"){ regexpList[key] = dojo.data.util.filter.patternToRegExp(value, ignoreCase); } } for(var i = 0; i < arrayOfAllItems.length; ++i){ var match = true; var candidateItem = arrayOfAllItems[i]; for(var key in requestArgs.query){ var value = requestArgs.query[key]; if(!self._containsValue(candidateItem, key, value, regexpList[key])){ match = false; } } if(match){ items.push(candidateItem); } } }else{ // We want a copy to pass back in case the parent wishes to sort the array. We shouldn't allow resort // of the internal list so that multiple callers can get lists and sort without affecting each other. if(arrayOfAllItems.length> 0){ items = arrayOfAllItems.slice(0,arrayOfAllItems.length); } } findCallback(items, requestArgs); }; if(this._loadFinished){ filter(keywordArgs, this._arrayOfAllItems); }else{ if(this.url !== ""){ //If fetches come in before the loading has finished, but while //a load is in progress, we have to defer the fetching to be //invoked in the callback. if(this._loadInProgress){ this._queuedFetches.push({args: keywordArgs, filter: filter}); }else{ this._loadInProgress = true; var getArgs = { url: self.url, handleAs: "text" }; var getHandler = dojo.xhrGet(getArgs); getHandler.addCallback(function(data){ self._processData(data); filter(keywordArgs, self._arrayOfAllItems); self._handleQueuedFetches(); }); getHandler.addErrback(function(error){ self._loadInProgress = false; if(errorCallback){ errorCallback(error, keywordArgs); }else{ throw error; } }); } }else if(this._csvData){ this._processData(this._csvData); this._csvData = null; filter(keywordArgs, this._arrayOfAllItems); }else{ var error = new Error("dojox.data.CsvStore: No CSV source data was provided as either URL or String data input."); if(errorCallback){ errorCallback(error, keywordArgs); }else{ throw error; } } }
parameter | type | description |
---|---|---|
keywordArgs | Object | |
findCallback | Function | |
errorCallback | Function |