com.extjs.gxt.ui.client.store
Class Store<M extends ModelData>

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.store.Store<M>
Type Parameters:
M - the model data type
All Implemented Interfaces:
Observable
Direct Known Subclasses:
ListStore, TreeStore

public abstract class Store<M extends ModelData>
extends BaseObservable

The store class encapsulates a client side cache of ModelData objects which provide input data for components such as the ComboBox and DataView.

Events:
Filter : StoreEvent(store)
Fires when filters are applied and removed from the store.
Update : StoreEvent(store, model, record)
Fires when a model has been updated via its record.
Clear : StoreEvent(store)
Fires when the data cache has been cleared.


Field Summary
static int Add
          Add event type (value is 1110).
static int BeforeDataChanged
          BeforeDataChanged event type (value is 1100).
static int Clear
          Clear event type (value is 1140).
static int DataChanged
          DataChanged event type (value is 1102).
static int Filter
          Filter event type (value is 1105).
static int Remove
          Remove event type (value is 1120).
static int Sort
          Filter event type (value is 1107).
static int Update
          Update event type (value is 1130).
 
Constructor Summary
Store()
           
 
Method Summary
 void addFilter(StoreFilter filter)
          Adds a filter to the store.
 void addStoreListener(StoreListener listener)
          Adds a store listener.
 void applyFilters(java.lang.String property)
          Applies the current filters to the store.
 void clearFilters()
          Revert to a view of this store with no filtering applied.
 void commitChanges()
          Commit all items with outstanding changes.
 boolean contains(ModelData item)
          Returns true if the item is in this store.
 void filter(java.lang.String property)
          Filters the store using the given property.
 M findModel(M model)
          Returns the matching model in the cache using the model comparer to test for equality.
 java.util.List<StoreFilter> getFilters()
          Returns the store's filters.
 ModelComparer<M> getModelComparer()
          Returns the comparer used to comapare model instances.
 java.util.List<M> getModels()
          Returns the store's models.
 java.util.List<Record> getModifiedRecords()
          Gets all records modified since the last commit.
 Record getRecord(M item)
          Returns the record instance for the item.
 StoreSorter getStoreSorter()
          Returns the store sorter.
 boolean isFiltered()
          Returns true if this store is currently filtered.
 boolean isMonitorChanges()
          Returns true if the store is monitoring changes.
 void rejectChanges()
          Cancel outstanding changes on all changed records.
 void removeAll()
          Remove all items from the store and fires the Clear event.
 void removeFilter(StoreFilter filter)
          Removes a previously added filter.
 void removeStoreListener(StoreListener listener)
          Removes a store listener.
 void setModelComparer(ModelComparer<M> comparer)
          Sets the comparer to be used when comparing model instances.
 void setMonitorChanges(boolean monitorChanges)
          Sets whether the store should listen to change events on its children (defaults to false).
 void setStoreSorter(StoreSorter storeSorter)
          Sets the store's sorter.
 void update(M model)
          Notifies the store that the model has been updated and fires the Update event.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BeforeDataChanged

public static final int BeforeDataChanged
BeforeDataChanged event type (value is 1100).

See Also:
Constant Field Values

DataChanged

public static final int DataChanged
DataChanged event type (value is 1102).

See Also:
Constant Field Values

Filter

public static final int Filter
Filter event type (value is 1105).

See Also:
Constant Field Values

Sort

public static final int Sort
Filter event type (value is 1107).

See Also:
Constant Field Values

Add

public static final int Add
Add event type (value is 1110).

See Also:
Constant Field Values

Remove

public static final int Remove
Remove event type (value is 1120).

See Also:
Constant Field Values

Update

public static final int Update
Update event type (value is 1130).

See Also:
Constant Field Values

Clear

public static final int Clear
Clear event type (value is 1140).

See Also:
Constant Field Values
Constructor Detail

Store

public Store()
Method Detail

addFilter

public void addFilter(StoreFilter filter)
Adds a filter to the store.

Parameters:
filter - the store filter to add

addStoreListener

public void addStoreListener(StoreListener listener)
Adds a store listener.

Parameters:
listener - the listener to add

applyFilters

public void applyFilters(java.lang.String property)
Applies the current filters to the store.

Parameters:
property - the optional active property

clearFilters

public void clearFilters()
Revert to a view of this store with no filtering applied.


commitChanges

public void commitChanges()
Commit all items with outstanding changes. To handle updates for changes, subscribe to the Store's Update event, and perform updating when the operation parameter is Record.RecordUpdate.COMMIT.


contains

public boolean contains(ModelData item)
Returns true if the item is in this store.

Parameters:
item - the item
Returns:
true if container

filter

public void filter(java.lang.String property)
Filters the store using the given property.

Parameters:
property - the property to filter by

findModel

public M findModel(M model)
Returns the matching model in the cache using the model comparer to test for equality.

Parameters:
model - the model
Returns:
the matching model or null if no match

getFilters

public java.util.List<StoreFilter> getFilters()
Returns the store's filters.

Returns:
the filters

getModelComparer

public ModelComparer<M> getModelComparer()
Returns the comparer used to comapare model instances.

Returns:
the comparer

getModels

public java.util.List<M> getModels()
Returns the store's models.

Returns:
the items

getModifiedRecords

public java.util.List<Record> getModifiedRecords()
Gets all records modified since the last commit. Modified records are persisted across load operations (e.g., during paging).

Returns:
a list of modified records

getRecord

public Record getRecord(M item)
Returns the record instance for the item. Records are created on-demand and are cleared after a stores modifications are accepted or rejected.

Parameters:
item - the item
Returns:
the record for the item

getStoreSorter

public StoreSorter getStoreSorter()
Returns the store sorter.

Returns:
the store storter

isFiltered

public boolean isFiltered()
Returns true if this store is currently filtered.

Returns:
true if the store is filtered

isMonitorChanges

public boolean isMonitorChanges()
Returns true if the store is monitoring changes.

Returns:
the montitro changes state

rejectChanges

public void rejectChanges()
Cancel outstanding changes on all changed records.


removeAll

public void removeAll()
Remove all items from the store and fires the Clear event.


removeFilter

public void removeFilter(StoreFilter filter)
Removes a previously added filter.

Parameters:
filter - the filter to remove

removeStoreListener

public void removeStoreListener(StoreListener listener)
Removes a store listener.

Parameters:
listener - the store listener to remove

setModelComparer

public void setModelComparer(ModelComparer<M> comparer)
Sets the comparer to be used when comparing model instances.

Parameters:
comparer - the comparer

setMonitorChanges

public void setMonitorChanges(boolean monitorChanges)
Sets whether the store should listen to change events on its children (defaults to false). This method should be called prior to any models being added to the store when monitoring changes. Only model instances which implement ChangeEventSource may be monitored.

Parameters:
monitorChanges - true to monitor changes

setStoreSorter

public void setStoreSorter(StoreSorter storeSorter)
Sets the store's sorter.

Parameters:
storeSorter - the sorter

update

public void update(M model)
Notifies the store that the model has been updated and fires the Update event.

Parameters:
model - the updated model