|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gwtext.client.core.JsObject
com.gwtext.client.data.Store
public class Store
The Store class encapsulates a client side cache of Record
objects which provide input data for widgets such
as the GridPanel
, or the ComboBox
.
DataProxy
to access a data object unless you call loadData() directly
and pass in your data. The Store object has no knowledge of the format of the data returned by the Proxy.
A Store object uses its configured implementation of Reader
to Record
instances from the data object.
These records are cached and made available through accessor functions. Usage :
Object[][] states = new Object[][]{
new Object[]{"AL", "Alabama"},
new Object[]{"AK", "Alaska"},
new Object[]{"AZ", "Arizona"},
new Object[]{"AR", "Arkansas"},
new Object[]{"CA", "California"}};
Reader reader = new ArrayReader(new RecordDef(
new FieldDef[]{
new StringFieldDef("abbr"),
new StringFieldDef("state")
}));
Store store = new Store(proxy, reader);
XmlReader
,
JsonReader
,
HttpProxy
,
MemoryProxy
Field Summary | |
---|---|
protected com.google.gwt.core.client.JavaScriptObject |
configJS
|
Fields inherited from class com.gwtext.client.core.JsObject |
---|
jsObj |
Constructor Summary | |
---|---|
protected |
Store()
|
|
Store(DataProxy dataProxy,
Reader reader)
Create a Store using the specified DataProxy and Reader . |
|
Store(DataProxy dataProxy,
Reader reader,
boolean remoteSort)
Create a Store using the specified DataProxy and Reader . |
|
Store(DataProxy dataProxy,
Reader reader,
UrlParam[] baseParams,
SortState initialSortState,
boolean remoteSort)
Create a Store using the specified configuration. |
|
Store(com.google.gwt.core.client.JavaScriptObject jsObj)
|
|
Store(Reader reader)
Create a Store using the specified Reader . |
|
Store(RecordDef recordDef)
Create a Store using the specified RecordDef . |
Method Summary | |
---|---|
void |
add(Record record)
Add a Record to the Store and fires the add event. |
void |
add(Record[] records)
Add Records to the Store and fires the add event. |
void |
addSorted(Record record)
(Local sort only) Inserts the passed the record in the Store at the index where it should go based on the current sort information. |
void |
addStoreListener(StoreListener listener)
Add a Store listener. |
void |
clearFilter()
Revert to a view of the Record cache / snapshot with no filtering applied. |
void |
clearFilter(boolean suppressEvent)
Revert to a view of the Record cache with no filtering applied. |
void |
clearSortState(boolean reload)
Clears the Stores internal sort state. |
void |
commitChanges()
Commit all Records with outstanding changes. |
void |
each(StoreTraversalCallback cb)
Calls the specified function for each of the Records in the cache. |
void |
filter(java.lang.String field,
RegExp regexp)
Filter the records by a specified property using a Regular expression. |
void |
filter(java.lang.String field,
java.lang.String value)
Filter the records by a specified property . |
void |
filter(java.lang.String field,
java.lang.String value,
boolean anyMatch)
Filter the records by a specified property . |
void |
filterBy(StoreTraversalCallback cb)
Filter by a function. |
int |
find(java.lang.String propname,
java.lang.String value,
int startIndex,
boolean anymatch,
boolean casesensitive)
Finds the index of the first matching record in this store by a specific property/value. |
Record |
getAt(int index)
Returns the record at the specified index. |
UrlParam[] |
getBaseParams()
Return the base params. |
Record |
getById(java.lang.String id)
Get the Record with the specified id. |
int |
getCount()
Gets the number of cached records. |
java.lang.String[] |
getFields()
|
com.google.gwt.core.client.JavaScriptObject |
getJsObj()
|
Record[] |
getModifiedRecords()
Gets all records modified since the last commit. |
Record[] |
getRange(int startIndex,
int endIndex)
Returns a range of Records between specified indices. |
Record |
getRecordAt(int index)
Returns the record at the specified index. |
Record[] |
getRecords()
Return all the Records in the Store. |
com.google.gwt.core.client.JavaScriptObject |
getRecordsAsJS()
|
SortState |
getSortState()
Returns the sort state of the Store. |
int |
getTotalCount()
Gets the total number of records in the dataset as returned by the server. |
int |
indexOf(Record record)
Get the index within the cache of the passed Record. |
int |
indexOfId(java.lang.String id)
Get the index within the cache of the Record with the passed id. |
void |
insert(int index,
Record record)
Inserts Records to the Store at the given index and fires the add event. |
void |
insert(int index,
Record[] records)
Inserts Records to the Store at the given index and fires the add event. |
void |
load()
Loads the Record cache from the configured Proxy using the configured Reader. |
void |
load(int start,
int limit)
Loads the Record cache from the configured Proxy using the configured Reader. |
void |
load(UrlParam[] params)
Loads the Record cache from the configured Proxy using the configured Reader. |
void |
load(UrlParam[] params,
boolean add)
Loads the Record cache from the configured Proxy using the configured Reader. |
void |
loadJsonData(java.lang.String jsonString,
boolean append)
Load data from a local Json String |
void |
loadXmlData(java.lang.String xmlString,
boolean append)
Load data from a local XML String. |
void |
loadXmlDataFromUrl(java.lang.String url,
boolean append)
Load data from XML returned from a URL. |
Record[] |
query(java.lang.String field,
RegExp regexp)
Query the records by a specified property. |
Record[] |
query(java.lang.String field,
java.lang.String value)
Query the records by a specified property. |
Record[] |
query(java.lang.String field,
java.lang.String value,
boolean anyMatch)
Query the records by a specified property. |
Record[] |
queryBy(StoreQueryFunction queryFunction)
Query by a function. |
void |
rejectChanges()
Cancel outstanding changes on all changed records. |
void |
reload()
Reloads the Record cache from the configured Proxy using the configured Reader and the options from the last load operation performed. |
void |
reload(UrlParam[] params)
Reloads the Record cache from the configured Proxy using the configured Reader and the options from the last load operation performed. |
void |
reload(UrlParam[] params,
boolean add)
Reloads the Record cache from the configured Proxy using the configured Reader and the options from the last load operation performed. |
void |
remove(Record record)
Remove a Record from the Store and fires the remove event. |
void |
removeAll()
Remove all Records from the Store and fires the clear event. |
void |
setAutoLoad(boolean autoLoad)
If true, this store's load method is automatically called after creation. |
void |
setBaseParams(UrlParam[] baseParams)
Url params which are to be sent as parameters on any HTTP request. |
void |
setDataProxy(DataProxy proxy)
The Proxy object which provides access to a data object.. |
void |
setDefaultSort(java.lang.String field,
SortDir sortDir)
Sets the default sort column and order to be used by the next load operation. |
void |
setDefaultSort(java.lang.String field,
java.lang.String sortDir)
Deprecated. Use setDefaultSort(String, com.gwtext.client.core.SortDir) |
void |
setInitialSortState(SortState initialSortState)
Set the initial sort state. |
void |
setPruneModifiedRecords(boolean pruneModifiedRecords)
True to clear all modified record information each time the store is loaded or when a record is removed. |
void |
setReader(Reader reader)
The Reader object which processes the data object and returns an Array of Ext.data.record objects which are cached keyed by their id property. |
void |
setRecordDef(RecordDef recordDef)
Sets the record def for the Store. |
void |
setRemoteSort(boolean remoteSort)
True if sorting is to be handled by requesting the Proxy to provide a refreshed version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false). |
void |
setSortInfo(SortState sortInfo)
The initial field to sort and its direction |
void |
setStoreId(java.lang.String storeId)
If passed, the id to use to register with the StoreMgr. |
void |
setUrl(java.lang.String url)
If passed, an HttpProxy is created for the passed URL. |
void |
sort(java.lang.String field)
Sort the Records. |
void |
sort(java.lang.String field,
SortDir direction)
Sort the Records. |
void |
sort(java.lang.String field,
java.lang.String direction)
Deprecated. Use sort(String, com.gwtext.client.core.SortDir) |
float |
sum(java.lang.String field)
Sums the value of property for each record between start and end and returns the result. |
float |
sum(java.lang.String field,
int startIndex,
int endIndex)
Sums the value of property for each record between start and end and returns the result. |
Methods inherited from class com.gwtext.client.core.JsObject |
---|
getProperties, isCreated, setJsObj |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected com.google.gwt.core.client.JavaScriptObject configJS
Constructor Detail |
---|
protected Store()
public Store(com.google.gwt.core.client.JavaScriptObject jsObj)
public Store(RecordDef recordDef)
RecordDef
. Data can be added to the Store using
add(Record)
recordDef
- the record defpublic Store(Reader reader)
Reader
. Use this constructor when you're loading data using
loadXmlData(java.lang.String, boolean)
. When calling load()
, you need to provide a DataProxy so use Store(DataProxy dataProxy, Reader reader)
constructor.
reader
- the readerpublic Store(DataProxy dataProxy, Reader reader)
DataProxy
and Reader
.
dataProxy
- the data proxyreader
- the readerpublic Store(DataProxy dataProxy, Reader reader, boolean remoteSort)
DataProxy
and Reader
.
dataProxy
- the data proxyreader
- the readerremoteSort
- true to enable remote sort of the datapublic Store(DataProxy dataProxy, Reader reader, UrlParam[] baseParams, SortState initialSortState, boolean remoteSort)
dataProxy
- the data proxyreader
- the readerbaseParams
- base params which are to be sent as parameters on any HTTP request. Used only for Http based proxies.initialSortState
- the initial sort field name and directionremoteSort
- true to enable remote sortMethod Detail |
---|
public com.google.gwt.core.client.JavaScriptObject getJsObj()
getJsObj
in class JsObject
public UrlParam[] getBaseParams()
public void add(Record record)
record
- the Record to addpublic void add(Record[] records)
records
- the Records to addpublic void addSorted(Record record)
record
- the record to addpublic void clearSortState(boolean reload)
reload
- true to reload the store after clearing the sort statepublic void clearFilter()
filter(String, String)
is called.
Records added to the Store after filter is caleld will be lost if clearFilter is subsequently called.
public void clearFilter(boolean suppressEvent)
suppressEvent
- if true the filter is cleared silently without notifying listenerspublic void commitChanges()
Record.COMMIT
.
public void each(StoreTraversalCallback cb)
cb
- the Store traversal callbackpublic void filter(java.lang.String field, RegExp regexp)
field
- the filed to filter onregexp
- the regular expression to test field value againstpublic void filter(java.lang.String field, java.lang.String value)
field
- the filed to filter onvalue
- a string that the field should start withpublic void filter(java.lang.String field, java.lang.String value, boolean anyMatch)
field
- the filed to filter onvalue
- a string that the field should start withanyMatch
- true to match any part not just the beginningpublic void filterBy(StoreTraversalCallback cb)
cb
- the filter functionpublic int find(java.lang.String propname, java.lang.String value, int startIndex, boolean anymatch, boolean casesensitive)
propname
- the property namevalue
- the string that the property value should begin withstartIndex
- the index to start searching atanymatch
- true to match any part of the string, not just the beginningcasesensitive
- true for case sensitive comparison
public Record getRecordAt(int index)
getAt(int)
.
index
- the Store index
public Record getAt(int index)
index
- the Store index
public Record getById(java.lang.String id)
id
- the Record ID
public int getCount()
public Record[] getModifiedRecords()
public Record[] getRange(int startIndex, int endIndex)
startIndex
- the starting index (0 based)endIndex
- the ending index
public SortState getSortState()
public int getTotalCount()
public int indexOf(Record record)
record
- the Record to find
public int indexOfId(java.lang.String id)
id
- the Record ID
public void insert(int index, Record record)
index
- the start index at which to insert the passed Recordrecord
- the Record to insertpublic void insert(int index, Record[] records)
index
- the start index at which to insert the passed Recordsrecords
- the Records to insertpublic void load()
load(int, int)
, and the number of Records
to cache on each read from the Proxy. It is important to note that for remote data sources, loading is asynchronous,
and this call will return before the new data has been loaded. Perform any post-processing in a "load" event handler.
public void load(int start, int limit)
load(int, int)
, and the number of Records
to cache on each read from the Proxy. It is important to note that for remote data sources, loading is asynchronous,
and this call will return before the new data has been loaded. Perform any post-processing in a "load" event handler.
start
- start positionlimit
- limitpublic void load(UrlParam[] params)
load(int, int)
, and the number of Records
to cache on each read from the Proxy. It is important to note that for remote data sources, loading is asynchronous,
and this call will return before the new data has been loaded. Perform any post-processing in a "load" event handler.
params
- the load paramspublic void load(UrlParam[] params, boolean add)
load(int, int)
, and the number of Records
to cache on each read from the Proxy. It is important to note that for remote data sources, loading is asynchronous,
and this call will return before the new data has been loaded. Perform any post-processing in a "load" event handler.
params
- the load paramsadd
- true to append loaded records rather than replace the current cachepublic void reload()
public void loadJsonData(java.lang.String jsonString, boolean append)
jsonString
- the Json Stringappend
- true to append to the Storepublic void loadXmlDataFromUrl(java.lang.String url, boolean append)
url
- the url that returns the XML dataappend
- true to append recordspublic void loadXmlData(java.lang.String xmlString, boolean append)
xmlString
- the XML dataappend
- true to append recordspublic void reload(UrlParam[] params)
params
- the request paramspublic void reload(UrlParam[] params, boolean add)
params
- the request paramsadd
- true to append loaded records rather than replace the current cachepublic Record[] query(java.lang.String field, java.lang.String value)
field
- the field to query onvalue
- a string that the field should start with
public Record[] query(java.lang.String field, java.lang.String value, boolean anyMatch)
field
- the field to query onvalue
- a string that the field should start withanyMatch
- true to match any part not just the beginning
public Record[] query(java.lang.String field, RegExp regexp)
field
- the field to query onregexp
- a RegExp to test against the field
public Record[] queryBy(StoreQueryFunction queryFunction)
queryFunction
- the query function
public void rejectChanges()
public void remove(Record record)
record
- the record to removepublic void removeAll()
public void setDefaultSort(java.lang.String field, SortDir sortDir)
field
- the name of the field to sort bysortDir
- the sort orderpublic void setDefaultSort(java.lang.String field, java.lang.String sortDir)
setDefaultSort(String, com.gwtext.client.core.SortDir)
field
- the name of the field to sort bysortDir
- the sort order, "ASC" or "DESC" (defaults to "ASC")public void sort(java.lang.String field)
field
- the name of the field to sort bypublic void sort(java.lang.String field, SortDir direction)
field
- the name of the field to sort bydirection
- the sort orderpublic void sort(java.lang.String field, java.lang.String direction)
sort(String, com.gwtext.client.core.SortDir)
field
- the name of the field to sort bydirection
- the sort order, "ASC" or "DESC" (defaults to "ASC")public float sum(java.lang.String field)
field
- field on your records
public float sum(java.lang.String field, int startIndex, int endIndex)
field
- field on your recordsstartIndex
- the record index to start at (defaults to 0)endIndex
- the last record index to include
public Record[] getRecords()
public void addStoreListener(StoreListener listener)
listener
- the listenerpublic void setAutoLoad(boolean autoLoad)
autoLoad
- true to auto laodpublic void setBaseParams(UrlParam[] baseParams)
baseParams
- the base paramspublic void setDataProxy(DataProxy proxy)
proxy
- the data proxypublic void setPruneModifiedRecords(boolean pruneModifiedRecords)
pruneModifiedRecords
- true to prune modified recordspublic void setReader(Reader reader)
reader
- the readerpublic void setRemoteSort(boolean remoteSort)
remoteSort
- true to enable remote sortpublic void setSortInfo(SortState sortInfo)
sortInfo
- the sort infopublic void setStoreId(java.lang.String storeId)
storeId
- the store IDpublic void setUrl(java.lang.String url)
url
- the urlpublic void setRecordDef(RecordDef recordDef)
recordDef
- the stores record defpublic void setInitialSortState(SortState initialSortState)
initialSortState
- the initial sort statepublic com.google.gwt.core.client.JavaScriptObject getRecordsAsJS()
public java.lang.String[] getFields()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |