com.extjs.gxt.ui.client.data
Interface TreeModel

All Superinterfaces:
ChangeEventSource, Model, ModelData
All Known Implementing Classes:
BaseTreeModel, TreeStoreModel

public interface TreeModel
extends Model

A Model that supports parent and children. Change events bubble to parent elements.

Events:
Update : ChangeEvent(source)
Fires after the the model is updated.
Add : ChangeEvent(source, parent, item, index)
Fires after a child model is added.
Remove : ChangeEvent(source, parent, item)
Fires after a child model is added.


Field Summary
 
Fields inherited from interface com.extjs.gxt.ui.client.data.ChangeEventSource
Add, Remove, Update
 
Method Summary
 void add(ModelData child)
          Adds a child to the model.
 ModelData getChild(int index)
          Returns the child at the given index.
 int getChildCount()
          Returns the child count.
 java.util.List<ModelData> getChildren()
          Returns the model's children.
 TreeModel getParent()
          Returns the model's parent.
 int indexOf(ModelData child)
          Returns the index of the child.
 void insert(ModelData child, int index)
          Inserts a child.
 boolean isLeaf()
          Returns true if the model is a leaf and has children.
 void remove(ModelData child)
          Removes a child.
 void removeAll()
          Removes all the children.
 void setParent(TreeModel parent)
          Sets the model's parent.
 
Methods inherited from interface com.extjs.gxt.ui.client.data.ModelData
get, getProperties, getPropertyNames, remove, set
 
Methods inherited from interface com.extjs.gxt.ui.client.data.ChangeEventSource
addChangeListener, notify, removeChangeListener, removeChangeListeners, setSilent
 

Method Detail

add

void add(ModelData child)
Adds a child to the model.

Parameters:
child - the model to add

getChild

ModelData getChild(int index)
Returns the child at the given index.

Parameters:
index - the index
Returns:
the child

getChildCount

int getChildCount()
Returns the child count.

Returns:
the child count

getChildren

java.util.List<ModelData> getChildren()
Returns the model's children.

Returns:
the children

getParent

TreeModel getParent()
Returns the model's parent.

Returns:
the parent

indexOf

int indexOf(ModelData child)
Returns the index of the child.

Parameters:
child - the child
Returns:
the index

insert

void insert(ModelData child,
            int index)
Inserts a child.

Parameters:
child - the child to add
index - the insert location

isLeaf

boolean isLeaf()
Returns true if the model is a leaf and has children. The method provides the ability to mark a model as having children before the children have been added.

Returns:
true for leaf

remove

void remove(ModelData child)
Removes a child.

Parameters:
child - the child to remove

removeAll

void removeAll()
Removes all the children.


setParent

void setParent(TreeModel parent)
Sets the model's parent.

Parameters:
parent - the new parent