com.extjs.gxt.ui.client.store
Class TreeStore<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.TreeStore<M>
All Implemented Interfaces:
Observable

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

A store for hierarchical data.

The parent child relationshiops are handled internally by the store. It is important to note that the store does not use the the parent and children of any TreeModel instances added to the store.

It is important to note the sorting behavior when working with TreeStore. When a sorter is set, it is applied to all existing models in the cache and the Sort event is fired. At this point, the sorter is enabled and active. All sorter will be applied to all inserts into the store.

Remote sorting is not supported with TreeStore.

Events:
BeforeDataChanged : TreeStoreEvent(store)
Fires before the store's data is changed. Apply applies when a store is bound to a loader.
DataChange : TreeStoreEvent(store)
Fires when the data cache has changed, and a widget which is using this Store as a Model cache should refresh its view.
Filter : TreeStoreEvent(store)
Fires when filters are applied and removed from the store.
Add : TreeStoreEvent(store, parent, child)
Fires when models have been added to the store.
Remove : TreeStoreEvent(store, parent, child)
Fires when a model has been removed from the store.
Update : TreeStoreEvent(store, model, record)
Fires when a model has been updated via its record.
Clear : TreeStoreEvent(store)
Fires when the data cache has been cleared.
Sort : TreeStoreEvent(store)
Fires after a sorter is applied to the store.


Field Summary
 
Fields inherited from class com.extjs.gxt.ui.client.store.Store
Add, BeforeDataChanged, Clear, DataChanged, Filter, Remove, Sort, Update
 
Constructor Summary
TreeStore()
           
TreeStore(TreeLoader loader)
           
 
Method Summary
 void add(java.util.List<M> models, boolean addChildren)
          Adds the models to the root of the store and fires the Add event.
 void add(M item, boolean addChildren)
          Adds the items to the store and fires the Add event.
 void add(M parent, java.util.List<M> children, boolean addChildren)
          Adds the models to the given parent and fires the Add event.
 void add(M parent, M item, boolean addChildren)
          Adds the child to the parent and fires the Add event.
 java.util.List<M> getAllItems()
          Returns all the stores items.
 M getChild(int index)
          Returns the root level child.
 M getChild(M parent, int index)
          Returns the child at the given index.
 int getChildCount()
          Returns the root level child count.
 int getChildCount(M parent)
          Returns the child count for the parent.
 java.util.List<M> getChildren(M parent)
          Returns the children of the parent.
 TreeLoader getLoader()
          Returns the store's loader.
 M getParent(M item)
          Returns the parent of the item.
 java.util.List<M> getRootItems()
          Returns the root level items.
 void insert(java.util.List<M> models, int index, boolean addChildren)
          Inserts the models into the store and fires the Add event.
 void insert(M item, int index, boolean addChildren)
          Adds the item to the store and fires the Add event.
 void insert(M parent, java.util.List<M> children, int index, boolean addChildren)
          Inserts the children to the parent and fires the Add event.
 void insert(M parent, M model, int index, boolean addChildren)
          Adds the child to the parent and fires the Add event.
 void remove(M model)
          Removes the model from the store and fires the Remove event.
 void remove(M parent, M child)
          Removes the child from the parent and fires the Remove event.
 void removeAll()
          Remove all items from the store and fires the Clear event.
 void removeAll(M parent)
          Removes all the parent's children.
 void setSortInfo(SortInfo info)
          Sets the current sort info usen when sorting items in the store.
 void setStoreSorter(StoreSorter storeSorter)
          Sets the store's sorter.
 
Methods inherited from class com.extjs.gxt.ui.client.store.Store
addFilter, addStoreListener, applyFilters, clearFilters, commitChanges, contains, filter, findModel, getFilters, getModelComparer, getModels, getModifiedRecords, getRecord, getStoreSorter, isFiltered, isMonitorChanges, rejectChanges, removeFilter, removeStoreListener, setModelComparer, setMonitorChanges, update
 
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
 

Constructor Detail

TreeStore

public TreeStore()

TreeStore

public TreeStore(TreeLoader loader)
Method Detail

add

public void add(java.util.List<M> models,
                boolean addChildren)
Adds the models to the root of the store and fires the Add event.

Parameters:
models - the models to be added
addChildren - true to recursivly add all children

add

public void add(M item,
                boolean addChildren)
Adds the items to the store and fires the Add event.

Parameters:
item - the item to add
addChildren - true to recursivly add all children

add

public void add(M parent,
                java.util.List<M> children,
                boolean addChildren)
Adds the models to the given parent and fires the Add event.

Parameters:
parent - the parent
children - the children
addChildren - true to recursivly add all children

add

public void add(M parent,
                M item,
                boolean addChildren)
Adds the child to the parent and fires the Add event.

Parameters:
parent - the parent item
item - the child item
addChildren - true to recursivly add all children

getAllItems

public java.util.List<M> getAllItems()
Returns all the stores items. The items are not returned in any order.

Returns:
the items

getChild

public M getChild(int index)
Returns the root level child.

Parameters:
index - the index
Returns:
the child

getChild

public M getChild(M parent,
                  int index)
Returns the child at the given index.

Parameters:
parent - the parent model
index - the index
Returns:
the child of the parent at the given index

getChildCount

public int getChildCount()
Returns the root level child count.

Returns:
the child count

getChildCount

public int getChildCount(M parent)
Returns the child count for the parent.

Parameters:
parent - the parent
Returns:
the child count or -1 if parent not found in the store

getChildren

public java.util.List<M> getChildren(M parent)
Returns the children of the parent.

Parameters:
parent - the children
Returns:
the children or null if parent not found in stote

getLoader

public TreeLoader getLoader()
Returns the store's loader.

Returns:
the loader

getParent

public M getParent(M item)
Returns the parent of the item.

Parameters:
item - the item
Returns:
the item's parent

getRootItems

public java.util.List<M> getRootItems()
Returns the root level items.

Returns:
the items

insert

public void insert(java.util.List<M> models,
                   int index,
                   boolean addChildren)
Inserts the models into the store and fires the Add event.

Parameters:
models - the models to insert
index - the insert index
addChildren - true to recursivly add all children

insert

public void insert(M item,
                   int index,
                   boolean addChildren)
Adds the item to the store and fires the Add event.

Parameters:
item - the item to insert
index - the insert index
addChildren - true to recursivly add all children

insert

public void insert(M parent,
                   java.util.List<M> children,
                   int index,
                   boolean addChildren)
Inserts the children to the parent and fires the Add event.

Parameters:
parent - the parent
children - the children
index - the insert index
addChildren - true to recursivly add all children

insert

public void insert(M parent,
                   M model,
                   int index,
                   boolean addChildren)
Adds the child to the parent and fires the Add event.

Parameters:
parent - the parent model
model - the child model
index - the insert index
addChildren - true to recursivly add all children

remove

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

Parameters:
model - the item to be removed

remove

public void remove(M parent,
                   M child)
Removes the child from the parent and fires the Remove event.

Parameters:
parent - the parent model
child - the child model

removeAll

public void removeAll()
Description copied from class: Store
Remove all items from the store and fires the Clear event.

Overrides:
removeAll in class Store<M extends ModelData>

removeAll

public void removeAll(M parent)
Removes all the parent's children.

Parameters:
parent - the parent

setSortInfo

public void setSortInfo(SortInfo info)
Sets the current sort info usen when sorting items in the store.

Parameters:
info - the sort info

setStoreSorter

public void setStoreSorter(StoreSorter storeSorter)
Description copied from class: Store
Sets the store's sorter.

Overrides:
setStoreSorter in class Store<M extends ModelData>
Parameters:
storeSorter - the sorter