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.Sort : StoreEvent(store)
Fires after the store's data has been changed due to sorting.
Store.Add : StoreEvent(store, models, index)
Fires when models have been added to the store.
Store.Remove : StoreEvent(store, model)
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
 
Fields inherited from class com.extjs.gxt.ui.client.store.Store
Add, BeforeDataChanged, Clear, DataChanged, Filter, Remove, Sort, 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.
 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.
 void insert(M model, int index)
          Inserts the model to the store at the given index and fires the Add event.
 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.
 
Methods inherited from class com.extjs.gxt.ui.client.store.Store
addFilter, addStoreListener, applyFilters, clearFilters, commitChanges, contains, equals, filter, filter, findModel, findModel, findModel, findModels, getFilters, getKeyProvider, getModelComparer, getModels, getModifiedRecords, getRecord, getStoreSorter, hasRecord, isFiltered, isMonitorChanges, rejectChanges, removeAll, removeFilter, removeStoreListener, setKeyProvider, setModelComparer, setMonitorChanges, setStoreSorter, update
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(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