Provides the abilty to asynchronously lazy load a TreeNodes children. An AsyncTreeNode
is assigned a
TreeLoader which is reponsible for fetching the tree data and loading it
into the tree as children. The
TreeLoader can be configured to load tree data from remote Json data
and
com.gwtext.client.widgets.tree.XMLTreeLoader can be use to load tree data from XML
returned from a remote URL.
Sample code for loading a Tree node using AsyncTreeNode and XmltreeLoader :
final TreePanel treePanel = new TreePanel("cb-tree", new TreePanelConfig() {
{
setAnimate(true);
setEnableDD(true);
setContainerScroll(true);
setRootVisible(true);
}
});
final XMLTreeLoader loader = new XMLTreeLoader(new XMLTreeLoaderConfig() {
{
setDataUrl("countries-cb.xml");
setMethod("get");
setRootTag("countries");
setFolderIdMapping("@id");
setLeafIdMapping("@id");
setFolderTitleMapping("@title");
setFolderTag("team");
setLeafTitleMapping("@title");
setLeafTag("country");
setQtipMapping("@qtip");
setDisabledMapping("@disabled");
setCheckedMapping("@checked");
setIconMapping("@icon");
setAttributeMappings(new String[]{"@rank"});
}
});
AsyncTreeNode root = new AsyncTreeNode("Countries", new AsyncTreeNodeConfig() {
{
setLoader(loader);
}
});
treePanel.setRootNode(root);
treePanel.render();
root.expand();
treePanel.expandAll();
The above code loads a Tree using the following XML data - countries-cb.xml
<countries>
<team id="team-a" title="Team A" icon="images/silk/flag_yellow.gif" checked="true">
<country title="Brazil" qtip="Rank 2" rank="2" checked="false"/>
<country title="Canada" qtip="Rank 3" rank="3" checked="false"/>
<country title="China" qtip="Rank 4" rank="4" checked="false"/>
</team>
<team title="Team B" icon="images/silk/flag_blue.gif">
<country title="Germany" qtip="Captain" checked="true" rank="1"/>
<country title="France" qtip="Rank 2" rank="2" checked="false"/>
<country title="Canada" qtip="Rank 3" rank="3" checked="false"/>
<country title="India" qtip="Rank 4" rank="4" checked="false"/>
<country title="Seychelles" qtip="Rank 5" rank="5" checked="false"/>
</team>
<team title="Team C" icon="images/silk/flag_green.gif">
<country title="United States" qtip="Captain - Rank 1" checked="true" rank="1"/>
<country title="Japan" qtip="Rank 2" rank="2" checked="false"/>
<country title="Italy" qtip="Rank 3" rank="3" checked="false"/>
<country title="Finland" qtip="Rank 4" rank="4" checked="false"/>
</team>
</countries>
See Also: TreeLoader See Also: com.gwtext.client.widgets.tree.XMLTreeLoader |