com.extjs.gxt.ui.client.store
Class ListStore<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>
          extended by com.extjs.gxt.ui.client.store.ListStore<M>
All Implemented Interfaces:
Observable
Direct Known Subclasses:
GroupingStore

public class ListStore<M extends ModelData>
extends Store<M>

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

Events:
Store.BeforeDataChanged : StoreEvent(store)
Fires before the store's data is changed. Apply applies when a store is bound to a loader.
Store.DataChange : StoreEvent(store)
Fires when the data cache has changed, and a widget which is using this Store as a ModelData cache should refresh its view.
Store.Filter : StoreEvent(store)
Fires when filters are applied and removed from the store.
Store.BeforeClear : StoreEvent(store)
Fires before the store is sorted. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Store.BeforeSort : StoreEvent(store, sortInfo)
Fires before the store's data has been changed due to sorting. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean) .
Store.Sort : StoreEvent(store, sortInfo)
Fires after the store's data has been changed due to sorting.
Store.BeforeAdd : StoreEvent(store, models, index)
Fires before models have been added to the store. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Store.Add : StoreEvent(store, models, index)
Fires when models have been added to the store.
Store.BeforeRemove : StoreEvent(store, model, index)
Fires before a model has been removed from the store. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Store.Remove : StoreEvent(store, model, index)
Fires when a model has been removed from the store.
Store.Update : StoreEvent(store, model, record)
Fires when a model has been updated via its record.
Store.Clear : StoreEvent(store)
Fires when the data cache has been cleared.


Field Summary
protected  ListLoadConfig config
           
protected  ListLoader<ListLoadResult<M>> loader
           
 
Fields inherited from class com.extjs.gxt.ui.client.store.Store
Add, all, BeforeAdd, BeforeClear, BeforeDataChanged, BeforeRemove, BeforeSort, Clear, DataChanged, Filter, filterBeginsWith, filtered, filterProperty, filters, filtersEnabled, modified, recordMap, Remove, snapshot, Sort, sortInfo, storeSorter, Update
 
Constructor Summary
ListStore()
          Creates a new store.
ListStore(ListLoader loader)
          Creates a new store.
 
Method Summary
 void add(java.util.List<? extends M> models)
          Adds the models to the store and fires the Add event.
 void add(M model)
          Adds the model to the store and fires the Add event.
protected  void applySort(boolean supressEvent)
           
protected  void fireStoreEvent(EventType type, Record.RecordUpdate operation, Record record)
           
 M getAt(int index)
          Get the model at the specified index.
 int getCount()
          Gets the number of cached records.
 ListLoadConfig getLoadConfig()
          Returns the store's last processed load config if available.
 ListLoader<? extends ListLoadResult<M>> getLoader()
          Returns the store's loader
 java.util.List<M> getRange(int start, int end)
          Returns a range of models between specified indices.
 Style.SortDir getSortDir()
          Returns the current sort direction.
 java.lang.String getSortField()
          Returns the current sort field.
 SortInfo getSortState()
          Returns the current sort state of this store.
 int indexOf(M model)
          Returns the index of the model in this store.
 void insert(java.util.List<? extends M> models, int index)
          Inserts the models to the store at the given index and fires the Add event.
protected  void insert(java.util.List<? extends M> items, int index, boolean supressEvent)
           
 void insert(M model, int index)
          Inserts the model to the store at the given index and fires the Add event.
protected  void onBeforeLoad(LoadEvent le)
           
protected  void onLoad(LoadEvent le)
           
protected  void onLoadException(LoadEvent le)
           
 void remove(int index)
           
 void remove(M model)
          Remove a item from the store and fires the Remove event.
 void setDefaultSort(java.lang.String field, Style.SortDir dir)
          Sets the default sort column and order to be used by the next load operation.
 void setSortDir(Style.SortDir dir)
          Sets the sort direction.
 void setSortField(java.lang.String field)
          Sets the sort field.
 void sort(java.lang.String field, Style.SortDir sortDir)
          Sorts the store.
protected  void sortData(java.lang.String field, Style.SortDir direction)
           
 
Methods inherited from class com.extjs.gxt.ui.client.store.Store
addFilter, addStoreListener, afterCommit, afterEdit, afterReject, applyFilters, clearFilters, commitChanges, contains, createStoreEvent, equals, filter, filter, findModel, findModel, findModel, findModels, getFilters, getKeyProvider, getModelComparer, getModels, getModifiedRecords, getRecord, getStoreSorter, hasRecord, isFiltered, isFiltered, isMonitorChanges, onModelChange, registerModel, rejectChanges, removeAll, removeFilter, removeStoreListener, setKeyProvider, setModelComparer, setMonitorChanges, setStoreSorter, swapModelInstance, unregisterModel, update
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected ListLoadConfig config

loader

protected ListLoader<ListLoadResult<M extends ModelData>> loader
Constructor Detail

ListStore

public ListStore()
Creates a new store.


ListStore

public ListStore(ListLoader loader)
Creates a new store.

Parameters:
loader - the loader instance
Method Detail

add

public void add(java.util.List<? extends M> models)
Adds the models to the store and fires the Add event.

Parameters:
models - the models to add

add

public void add(M model)
Adds the model to the store and fires the Add event.

Parameters:
model - the model to add

getAt

public M getAt(int index)
Get the model at the specified index.

Parameters:
index - the index of the model to find
Returns:
the model at the passed index

getCount

public int getCount()
Gets the number of cached records.

Returns:
the number of models in the store's cache.

getLoadConfig

public ListLoadConfig getLoadConfig()
Returns the store's last processed load config if available.

Returns:
the load config

getLoader

public ListLoader<? extends ListLoadResult<M>> getLoader()
Returns the store's loader

Returns:
the loader or null

getRange

public java.util.List<M> getRange(int start,
                                  int end)
Returns a range of models between specified indices.

Parameters:
start - the starting index
end - the ending index
Returns:
the list of models

getSortDir

public Style.SortDir getSortDir()
Returns the current sort direction.

Returns:
the sort direction

getSortField

public java.lang.String getSortField()
Returns the current sort field.

Returns:
the sort field

getSortState

public SortInfo getSortState()
Returns the current sort state of this store.

Returns:
the sort state

indexOf

public int indexOf(M model)
Returns the index of the model in this store.

Parameters:
model - the model
Returns:
the index

insert

public void insert(java.util.List<? extends M> models,
                   int index)
Inserts the models to the store at the given index and fires the Add event.

Parameters:
models - the models to insert
index - the insert location

insert

public void insert(M model,
                   int index)
Inserts the model to the store at the given index and fires the Add event.

Parameters:
model - the model to insert
index - the insert location

remove

public void remove(int index)

remove

public void remove(M model)
Remove a item from the store and fires the Remove event.

Parameters:
model - the model to remove

setDefaultSort

public void setDefaultSort(java.lang.String field,
                           Style.SortDir dir)
Sets the default sort column and order to be used by the next load operation.

Parameters:
field - the name of the field to sort by
dir - the sort direction

setSortDir

public void setSortDir(Style.SortDir dir)
Sets the sort direction.

Parameters:
dir - the sort direction

setSortField

public void setSortField(java.lang.String field)
Sets the sort field.

Parameters:
field - the sort field

sort

public void sort(java.lang.String field,
                 Style.SortDir sortDir)
Sorts the store.

If remote sorting is used, the sort is performed on the server, and the cache is reloaded. If local sorting is used, the cache is sorted internally.

Parameters:
field - the field to sort by
sortDir - the sort dir

applySort

protected void applySort(boolean supressEvent)
Overrides:
applySort in class Store<M extends ModelData>

fireStoreEvent

protected void fireStoreEvent(EventType type,
                              Record.RecordUpdate operation,
                              Record record)
Overrides:
fireStoreEvent in class Store<M extends ModelData>

insert

protected void insert(java.util.List<? extends M> items,
                      int index,
                      boolean supressEvent)

onBeforeLoad

protected void onBeforeLoad(LoadEvent le)

onLoad

protected void onLoad(LoadEvent le)

onLoadException

protected void onLoadException(LoadEvent le)

sortData

protected void sortData(java.lang.String field,
                        Style.SortDir direction)