public class ResultTree extends Tree
Tree
API, used to handle hierarchical
data, whose nodes are DataSource records which are retrieved from a server. Modifying ResultTrees
ResultTree
nodes cannot be directly added or removed from a paged
ResultTree
via Tree
APIs such as Tree.add()
or
Tree.remove()
, since such trees are considered to be read-only by
virtue of containing ResultSet
s, which are read-only data structures. Even in other
FetchMode
s, calling such APIs will only update the local cache of the ResultTree,
rather than triggering any server traffict to update the DataSource.
Use DataSource.addData()
/removeData()
to add/remove rows from the DataSource
, and the ResultTree
will reflect the changes automatically. Alternatively, the DataSource.updateCaches()
method may be called to only update local caches of the DataSource in question, without
generating any server traffic.
To create a locally modifiable cache of records from a DataSource, you can use DataSource.fetchData()
to retrieve a List of records which can be
modified directly, or you can create a client-only DataSource
from the retrieved data
to share a modifiable cache between several DataBoundComponents.
RecordList.SortNormalizer
jsObj
config, configOnly, factoryCreated, factoryProperties, id, scClassName
Constructor and Description |
---|
ResultTree() |
ResultTree(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
Tree |
applyFilter(Tree tree,
Criteria criteria,
TreeFilterMode filterMode,
DataSource dataSource)
The ResultTree will call applyFilter() when it needs to locally filter the tree using the current filter criteria.
|
Tree |
applyFilter(Tree tree,
Criteria criteria,
TreeFilterMode filterMode,
DataSource dataSource,
DSRequest requestProperties)
The ResultTree will call applyFilter() when it needs to locally filter the tree using the current filter criteria.
|
int |
compareCriteria(Criteria newCriteria,
Criteria oldCriteria)
Default behavior is to call
DataSource.compareCriteria() to
determine whether new criteria is equivalent to the old criteria (returns 0) or not. |
int |
compareCriteria(Criteria newCriteria,
Criteria oldCriteria,
DSRequest requestProperties)
Default behavior is to call
DataSource.compareCriteria() to
determine whether new criteria is equivalent to the old criteria (returns 0) or not. |
com.google.gwt.core.client.JavaScriptObject |
create() |
void |
dataArrived(TreeNode parentNode)
This callback fires whenever the resultTree receives new nodes from the server, after the new nodes have been integrated
into the tree.
|
TreeNode |
get(int pos)
Get the item in the openList at a particular position.
|
java.lang.String |
getAutoOpen()
Which nodes should be opened automatically - applied whenever
setRoot() is called, including during initialization and as part of a re-fetch caused, for example, by duplicate() or invalidateCache() . |
PreserveOpenState |
getAutoPreserveOpenState()
Controls what happens to the
"open state" - the set of
nodes opened or closed by the end user after tree data is loaded - when an entirely new tree of nodes is loaded from the
server, as a consequence of calling invalidateCache() or of changing criteria such that the current cache of nodes is dropped. |
java.lang.Boolean |
getAutoUpdateSiblingNodesOnDrag()
For
multi-link trees , indicates that we should
automatically
update the position values of old and new sibling
records
after a drag reparent or reposition-within-parent operation. |
boolean |
getCanReturnOpenFolders()
When using
fetchMode:"paged" and providing multiple levels of the tree in
one DSResponse, this property specifies the default value assumed for the canReturnOpenSubfoldersProperty when no
value for that property is provided for a node. |
java.lang.String |
getCanReturnOpenSubfoldersProperty()
When using
fetchMode:"paged" and providing multiple levels of the tree in
one DSResponse, canReturnOpenSubfoldersProperty may be set on any folder to indicate whether child folders
might be returned by the server already open. |
java.lang.String |
getChildCountProperty()
When using
fetchMode:"paged" and providing multiple levels of the tree in
one DSResponse, childCountProperty must be set for any folders that include only a partial list of
children. |
Criteria |
getCombinedCriteria()
|
AdvancedCriteria |
getCombinedCriteriaAsAdvancedCriteria()
|
Criteria |
getCriteria()
The filter criteria to use when fetching rows.
|
TreeNode[] |
getData()
Optional initial data for the tree.
|
DataSource |
getDataSource()
What
DataSource is this resultTree associated with? |
java.lang.Boolean |
getDefaultIsFolder()
Controls whether nodes are assumed to be folders or leaves by default.
|
java.lang.Boolean |
getDefaultNewNodesToRoot()
This attribute governs how to handle cache-synch when a new node is added to this dataSource with no explicit parentId.
|
java.lang.Boolean |
getDisableCacheSync()
By default when the data of this ResultTree's dataSource is modified, the ResultTree will be updated to display these
changes.
|
java.lang.Boolean |
getDiscardParentlessNodes()
When data is loaded from the server, should nodes with an explicit value for the
Tree.parentIdField which doesn't map to a valid parent node be
dropped? If set to false, for TreeGrid.loadDataOnDemand :false trees, parentless nodes will be added as children of the root node - for TreeGrid.loadDataOnDemand :true, they will be added as
children of the folder currently requesting children. |
FetchMode |
getFetchMode()
Mode of fetching records from server.
|
java.lang.Integer |
getFirstPositionValue()
If
autoUpdateSiblingNodesOnDrag is
in force, this is the value we will use to auto-update the position of a node when we cannot derive that value from the
existing value of a neighbor. |
Criteria |
getImplicitCriteria()
Criteria that are never shown to or edited by the user and are cumulative with any criteria provided via
DataBoundComponent.initialCriteria , setCriteria() etc. |
java.lang.Boolean |
getKeepParentsOnFilter()
If set, tree-based filtering is performed such that parent nodes are kept as long as they have children that match the
filter criteria, even if the parents themselves do not match the filter criteria.
|
java.lang.String |
getLinkDataAddOperation()
|
LinkDataFetchMode |
getLinkDataFetchMode()
The fetch mode for this tree's link data; ignored if this is not a
multi-link tree |
java.lang.String |
getLinkDataFetchOperation()
|
java.lang.String |
getLinkDataRemoveOperation()
|
DataSource |
getLinkDataSource()
This property allows you to specify the dataSource to be used for fetching link information
in a databound multilink tree.
|
java.lang.String |
getLinkDataSourceAsString()
This property allows you to specify the dataSource to be used for fetching link information
in a databound multilink tree.
|
java.lang.Boolean |
getLoadDataOnDemand()
Does this resultTree load data incrementally as folders within the tree are opened, or is it all loaded in a single
request? Must be true if
fetchMode is "paged" |
TreeModelType |
getModelType()
Selects the model used to construct the tree representation.
|
java.lang.String |
getOpenState()
Returns a snapshot of the current open state of this tree's data as a
TreeGridOpenState
object. |
static ResultTree |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.util.Map |
getPaletteDefaults()
This method returns a Map of config properties suitable for use as the "defaults"
attribute of a
PaletteNode . |
java.lang.Boolean |
getProgressiveLoading()
Sets
progressive loading mode for this ResultTree. |
TreeNode[] |
getRange(int start,
int end)
Get a range of items from the open list
|
java.lang.Integer |
getResultSize()
How many tree nodes to retrieve at once from each large set of children in the tree.
|
com.google.gwt.core.client.JavaScriptObject |
getRootNode()
This attribute may be used to specify a root value for the parentIdField of this resultTree.
|
java.lang.Boolean |
getSendNullParentInLinkDataCriteria()
For
multi-link tree s only, should we send up the parentId in fetch criteria if the criteria value is null? If
false, we remove the parentId from the criteria when fetching link data , if the criteria value is null
(as it will be by default when fetching the direct child nodes of the tree's root). |
java.lang.String[] |
getServerFilterFields()
For
fetchMode:"local" ResultTrees, this property lists field names that
will be sent to the server if they are present in the criteria. |
java.lang.Boolean |
getUpdateCacheFromRequest()
When a successful Add, Update or Remove type operation fires on this ResultTree's dataSource, if
DSResponse.data is unset, should we integrate the submitted data values
(from the request) into our data-set? |
boolean |
getUseSimpleCriteriaLOD()
Whether or not we should skip promotion of a simple criteria to an
AdvancedCriteria
when sending the DSRequest to load the children of a node in a loadDataOnDemand or fetchMode:"paged" ResultTree . |
void |
invalidateCache()
Manually invalidate this ResultTree's cache.
|
ResultTree |
setAutoOpen(java.lang.String autoOpen)
Which nodes should be opened automatically - applied whenever
setRoot() is called, including during initialization and as part of a re-fetch caused, for example, by duplicate() or invalidateCache() . |
ResultTree |
setAutoPreserveOpenState(PreserveOpenState autoPreserveOpenState)
Controls what happens to the
"open state" - the set of
nodes opened or closed by the end user after tree data is loaded - when an entirely new tree of nodes is loaded from the
server, as a consequence of calling invalidateCache() or of changing criteria such that the current cache of nodes is dropped. |
ResultTree |
setAutoUpdateSiblingNodesOnDrag(java.lang.Boolean autoUpdateSiblingNodesOnDrag)
For
multi-link trees , indicates that we should
automatically
update the position values of old and new sibling
records
after a drag reparent or reposition-within-parent operation. |
ResultTree |
setCanReturnOpenFolders(boolean canReturnOpenFolders)
When using
fetchMode:"paged" and providing multiple levels of the tree in
one DSResponse, this property specifies the default value assumed for the canReturnOpenSubfoldersProperty when no
value for that property is provided for a node. |
ResultTree |
setCanReturnOpenSubfoldersProperty(java.lang.String canReturnOpenSubfoldersProperty)
When using
fetchMode:"paged" and providing multiple levels of the tree in
one DSResponse, canReturnOpenSubfoldersProperty may be set on any folder to indicate whether child folders
might be returned by the server already open. |
ResultTree |
setChildCountProperty(java.lang.String childCountProperty)
When using
fetchMode:"paged" and providing multiple levels of the tree in
one DSResponse, childCountProperty must be set for any folders that include only a partial list of
children. |
void |
setChildren(TreeNode parent,
java.util.List newChildren)
Replaces the existing children of a parent node.
|
void |
setChildren(TreeNode parent,
java.util.List newChildren,
java.lang.Integer totalChildren)
Replaces the existing children of a parent node.
|
ResultTree |
setCriteria(Criteria criteria)
The filter criteria to use when fetching rows.
|
ResultTree |
setData(TreeNode... data)
Optional initial data for the tree.
|
ResultTree |
setDataSource(DataSource dataSource)
What
DataSource is this resultTree associated with? |
ResultTree |
setDefaultIsFolder(java.lang.Boolean defaultIsFolder)
Controls whether nodes are assumed to be folders or leaves by default.
|
ResultTree |
setDefaultNewNodesToRoot(java.lang.Boolean defaultNewNodesToRoot)
This attribute governs how to handle cache-synch when a new node is added to this dataSource with no explicit parentId.
|
static void |
setDefaultProperties(ResultTree resultTreeProperties)
Class level method to set the default properties of this class.
|
ResultTree |
setDisableCacheSync(java.lang.Boolean disableCacheSync)
By default when the data of this ResultTree's dataSource is modified, the ResultTree will be updated to display these
changes.
|
ResultTree |
setDiscardParentlessNodes(java.lang.Boolean discardParentlessNodes)
When data is loaded from the server, should nodes with an explicit value for the
Tree.parentIdField which doesn't map to a valid parent node be
dropped? If set to false, for TreeGrid.loadDataOnDemand :false trees, parentless nodes will be added as children of the root node - for TreeGrid.loadDataOnDemand :true, they will be added as
children of the folder currently requesting children. |
ResultTree |
setFetchMode(FetchMode fetchMode)
Mode of fetching records from server.
|
ResultTree |
setFirstPositionValue(java.lang.Integer firstPositionValue)
If
autoUpdateSiblingNodesOnDrag is
in force, this is the value we will use to auto-update the position of a node when we cannot derive that value from the
existing value of a neighbor. |
ResultTree |
setImplicitCriteria(Criteria implicitCriteria)
Criteria that are never shown to or edited by the user and are cumulative with any criteria provided via
DataBoundComponent.initialCriteria , setCriteria() etc. |
ResultTree |
setKeepParentsOnFilter(java.lang.Boolean keepParentsOnFilter)
If set, tree-based filtering is performed such that parent nodes are kept as long as they have children that match the
filter criteria, even if the parents themselves do not match the filter criteria.
|
ResultTree |
setLinkDataAddOperation(java.lang.String linkDataAddOperation)
|
ResultTree |
setLinkDataFetchMode(LinkDataFetchMode linkDataFetchMode)
The fetch mode for this tree's link data; ignored if this is not a
multi-link tree |
ResultTree |
setLinkDataFetchOperation(java.lang.String linkDataFetchOperation)
|
ResultTree |
setLinkDataRemoveOperation(java.lang.String linkDataRemoveOperation)
|
ResultTree |
setLinkDataSource(DataSource linkDataSource)
This property allows you to specify the dataSource to be used for fetching link information
in a databound multilink tree.
|
ResultTree |
setLinkDataSource(java.lang.String linkDataSource)
This property allows you to specify the dataSource to be used for fetching link information
in a databound multilink tree.
|
ResultTree |
setLoadDataOnDemand(java.lang.Boolean loadDataOnDemand)
Does this resultTree load data incrementally as folders within the tree are opened, or is it all loaded in a single
request? Must be true if
fetchMode is "paged" |
ResultTree |
setModelType(TreeModelType modelType)
Selects the model used to construct the tree representation.
|
void |
setOpenState(java.lang.String openState)
Reset the set of open folders within this tree's data to match the
TreeGridOpenState
object passed in. |
ResultTree |
setProgressiveLoading(java.lang.Boolean progressiveLoading)
Sets
progressive loading mode for this ResultTree. |
ResultTree |
setResultSize(java.lang.Integer resultSize)
How many tree nodes to retrieve at once from each large set of children in the tree.
|
void |
setRootNode(com.google.gwt.core.client.JavaScriptObject rootNode)
This attribute may be used to specify a root value for the parentIdField of this resultTree.
|
ResultTree |
setSendNullParentInLinkDataCriteria(java.lang.Boolean sendNullParentInLinkDataCriteria)
For
multi-link tree s only, should we send up the parentId in fetch criteria if the criteria value is null? If
false, we remove the parentId from the criteria when fetching link data , if the criteria value is null
(as it will be by default when fetching the direct child nodes of the tree's root). |
ResultTree |
setServerFilterFields(java.lang.String... serverFilterFields)
For
fetchMode:"local" ResultTrees, this property lists field names that
will be sent to the server if they are present in the criteria. |
ResultTree |
setUpdateCacheFromRequest(java.lang.Boolean updateCacheFromRequest)
When a successful Add, Update or Remove type operation fires on this ResultTree's dataSource, if
DSResponse.data is unset, should we integrate the submitted data values
(from the request) into our data-set? |
ResultTree |
setUseSimpleCriteriaLOD(boolean useSimpleCriteriaLOD)
Whether or not we should skip promotion of a simple criteria to an
AdvancedCriteria
when sending the DSRequest to load the children of a node in a loadDataOnDemand or fetchMode:"paged" ResultTree . |
void |
unloadChildren(TreeNode node)
Deprecated.
It's recommended that you instead use
Tree.reloadChildren()
to reload the children of a folder, or Tree.removeChildren() if you need to clear the cached children of a folder to add specific local data. |
java.lang.Boolean |
willFetchData(Criteria newCriteria)
Will changing the criteria for this resultTree require fetching new data from the server or can the new criteria be
satisfied from data already cached on the client?
|
add, add, add, add, addDataChangedHandler, addList, addList, addList, addList, allChildrenLoaded, closeAll, closeAll, closeAll, closeFolder, closeFolder, closeFolder, closeFolder, closeFolders, createNodeLocator, createNodeLocator, discoverTree, find, find, find, findById, findChildrenProperty, findIndex, findIndex, findIndex, findIndex, findNextIndex, findNextIndex, findNextIndex, findNextNodeIndex, findNextNodeIndex, findNextNodeIndex, findNodeIndex, findNodeIndex, findNodeIndex, findNodeIndex, getAllNodes, getAllNodes, getAllowFilterOnLinkFields, getAutoOpenRoot, getChildren, getChildrenProperty, getChildrenResultSet, getDataSourceAsString, getDefaultNodeTitle, getDescendantFolders, getDescendantFolders, getDescendantLeaves, getDescendantLeaves, getDescendantNodeLocators, getDescendantNodeLocators, getDescendants, getDescendants, getFilteredTree, getFilteredTree, getFolders, getIdField, getIsFolderProperty, getLeaves, getLength, getLevel, getLevel, getLinkData, getLinkPositionField, getLoadState, getMultiLinkParents, getName, getName, getNameProperty, getNodeLocator, getOpenList, getOpenProperty, getParent, getParentIdField, getParentPath, getParents, getParentsAndPositions, getPath, getPathDelim, getPathForOpenListIndex, getReportCollisions, getRoot, getRootValue, getSeparateFolders, getShowRoot, getSortFoldersBeforeLeaves, getTitle, getTitleProperty, hasChildren, hasFolders, hasLeaves, isDescendantOf, isFolder, isInAncestorChain, isLeaf, isLoaded, isMultiLinkTree, isOpen, isOpen, isOpen, isOpen, isParent, isRoot, linkDataChanged, linkNodes, loadChildren, loadChildren, move, move, nodeForRecord, openAll, openAll, openAll, openAll, openAll, openFolder, openFolders, reloadChildren, remove, remove, remove, remove, removeChildren, removeList, setAllowFilterOnLinkFields, setAutoOpenRoot, setChildrenProperty, setDataSource, setDefaultNodeTitle, setDefaultProperties, setIdField, setIsFolderProperty, setJavaScriptObject, setLinkData, setLinkPositionField, setMultiLinkTree, setNameProperty, setOpenProperty, setParentIdField, setPathDelim, setReportCollisions, setRoot, setRootValue, setRootValue, setSeparateFolders, setShowRoot, setSortFoldersBeforeLeaves, setTitleProperty
add, addAt, addDataChangedHandler, addList, addList, addListAt, contains, contains, containsAll, duplicate, equals, find, find, find, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findAll, findIndex, findIndex, findIndex, findIndex, findIndex, findIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, findNextIndex, first, getItems, getJsObj, getOrCreateJsObj, getProperty, getRangeList, getValueMap, indexOf, indexOf, intersect, isARecordList, isCreated, isEmpty, last, lastIndexOf, lastIndexOf, remove, removeAt, removeList, set, setLength, setSort, sort, sort, sortByProperty, sortByProperty, toArray
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName
public ResultTree()
public ResultTree(com.google.gwt.core.client.JavaScriptObject jsObj)
public static ResultTree getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public java.util.Map getPaletteDefaults()
PaletteNode
. Use it when you need to
work with PaletteNodes indirectly, such when setting up
TileRecord
s that will be used in a
TilePalette
. See
the dev tools overview
for examples of how to
assemble and acquire a suitable defaults object when you are creating a PaletteNode
indirectlypublic ResultTree setAutoOpen(java.lang.String autoOpen)
setRoot()
is called, including during initialization and as part of a re-fetch caused, for example, by duplicate()
or invalidateCache()
. Options are:
top-level node
- in databound trees, this node is
always hiddenloading data
on demand
, opens the top-level node
and all
of it's direct descendants - otherwise, opens all loaded nodes autoOpen
- New autoOpen value. Default value is "none"ResultTree
instance, for chaining setter callspublic java.lang.String getAutoOpen()
setRoot()
is called, including during initialization and as part of a re-fetch caused, for example, by duplicate()
or invalidateCache()
. Options are:
top-level node
- in databound trees, this node is
always hiddenloading data
on demand
, opens the top-level node
and all
of it's direct descendants - otherwise, opens all loaded nodes public ResultTree setAutoPreserveOpenState(PreserveOpenState autoPreserveOpenState)
"open state"
- the set of
nodes opened or closed by the end user after tree data is loaded - when an entirely new tree of nodes is loaded from the
server, as a consequence of calling invalidateCache()
or of changing criteria such that the current cache of nodes is dropped.autoPreserveOpenState
- New autoPreserveOpenState value. Default value is "whenUnique"ResultTree
instance, for chaining setter callspublic PreserveOpenState getAutoPreserveOpenState()
"open state"
- the set of
nodes opened or closed by the end user after tree data is loaded - when an entirely new tree of nodes is loaded from the
server, as a consequence of calling invalidateCache()
or of changing criteria such that the current cache of nodes is dropped.public ResultTree setAutoUpdateSiblingNodesOnDrag(java.lang.Boolean autoUpdateSiblingNodesOnDrag) throws java.lang.IllegalStateException
multi-link trees
, indicates that we should
automatically
update the position
values of old and new sibling
records
after a drag reparent or reposition-within-parent operation. For example, say you have a
tree like this (where the number in parentheses indicates the node's
position
value):A - B (1) - C (2) - D (3) E - F (1) - G (2)and you drag node C out and drop it between nodes F and G. This drag operation will spawn two update operations to the server: a "remove" to delete node C from parent A, and an "add" to re-add it under parent E. With
autoUpdateSiblingNodesOnDrag
in force, we
also automatically issue two "update" operations to the server - one to change the position
on node D to 2, and another to change the position on node G to 3. The end result of this
is that node position values are kept correct.
Please note the following:
autoUpdateSiblingNodesOnDrag
only works well if your position values are consecutive integersautoUpdateSiblingNodesOnDrag
- New autoUpdateSiblingNodesOnDrag value. Default value is (see below)ResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getAutoUpdateSiblingNodesOnDrag()
multi-link trees
, indicates that we should
automatically
update the position
values of old and new sibling
records
after a drag reparent or reposition-within-parent operation. For example, say you have a
tree like this (where the number in parentheses indicates the node's
position
value):A - B (1) - C (2) - D (3) E - F (1) - G (2)and you drag node C out and drop it between nodes F and G. This drag operation will spawn two update operations to the server: a "remove" to delete node C from parent A, and an "add" to re-add it under parent E. With
autoUpdateSiblingNodesOnDrag
in force, we
also automatically issue two "update" operations to the server - one to change the position
on node D to 2, and another to change the position on node G to 3. The end result of this
is that node position values are kept correct.
Please note the following:
autoUpdateSiblingNodesOnDrag
only works well if your position values are consecutive integerspublic ResultTree setCanReturnOpenFolders(boolean canReturnOpenFolders) throws java.lang.IllegalStateException
fetchMode:"paged"
and providing multiple levels of the tree in
one DSResponse, this property specifies the default value assumed for the canReturnOpenSubfoldersProperty
when no
value for that property is provided for a node.canReturnOpenFolders
- New canReturnOpenFolders value. Default value is falseResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic boolean getCanReturnOpenFolders()
fetchMode:"paged"
and providing multiple levels of the tree in
one DSResponse, this property specifies the default value assumed for the canReturnOpenSubfoldersProperty
when no
value for that property is provided for a node.public ResultTree setCanReturnOpenSubfoldersProperty(java.lang.String canReturnOpenSubfoldersProperty) throws java.lang.IllegalStateException
fetchMode:"paged"
and providing multiple levels of the tree in
one DSResponse, canReturnOpenSubfoldersProperty
may be set on any folder to indicate whether child folders
might be returned by the server already open. If the property is set to false on a folder then subfolders of that folder
are never allowed to be returned already open. This enables the paging mechanism to be more efficient in the amount of
data that it requests from the server. For example, setting the canReturnOpenSubfoldersProperty
value
to false
on a node is appropriate if the server-side code determines that the the node's children consist
of entirely leaf nodes.
canReturnOpenSubfoldersProperty
- New canReturnOpenSubfoldersProperty value. Default value is "canReturnOpenSubfolders"ResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdsetCanReturnOpenFolders(boolean)
public java.lang.String getCanReturnOpenSubfoldersProperty()
fetchMode:"paged"
and providing multiple levels of the tree in
one DSResponse, canReturnOpenSubfoldersProperty
may be set on any folder to indicate whether child folders
might be returned by the server already open. If the property is set to false on a folder then subfolders of that folder
are never allowed to be returned already open. This enables the paging mechanism to be more efficient in the amount of
data that it requests from the server. For example, setting the canReturnOpenSubfoldersProperty
value
to false
on a node is appropriate if the server-side code determines that the the node's children consist
of entirely leaf nodes.
getCanReturnOpenFolders()
public ResultTree setChildCountProperty(java.lang.String childCountProperty) throws java.lang.IllegalStateException
fetchMode:"paged"
and providing multiple levels of the tree in
one DSResponse, childCountProperty
must be set for any folders that include only a partial list of
children. For a deeper discussion see the Paging large sets of children section of the TreeDataBinding
overview.childCountProperty
- New childCountProperty value. Default value is "childCount"ResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String getChildCountProperty()
fetchMode:"paged"
and providing multiple levels of the tree in
one DSResponse, childCountProperty
must be set for any folders that include only a partial list of
children. For a deeper discussion see the Paging large sets of children section of the TreeDataBinding
overview.public ResultTree setCriteria(Criteria criteria)
setCriteria()
.
Depending on the result of compareCriteria()
and setting for fetchMode
, setting criteria may cause a trip to the server to get a new set of nodes, or may simply cause already-fetched nodes to be re-filtered according to the new criteria.
For a basic overview on when server fetches are generally performed, see fetchMode
. However, this is not the final determination of when server fetches occur. Criteria can be split into local criteria and server criteria by specifying serverFilterFields
. Thus, even when using fetchMode:"local" a new server fetch will occur if the server criteria changes. For details on how the criteria is split, see DataSource.splitCriteria()
.
Note: if criteria is being split to retrieve server criteria portion and the criteria is an AdvancedCriteria
, the criteria must consist of a single "and" operator and one or more simple criteria below it. No other logical operators may be used. In other words, the AdvancedCriteria
provided must be exactly representable by a simple criteria.
criteria
- the filter criteria. Default value is nullResultTree
instance, for chaining setter callspublic Criteria getCriteria()
setCriteria()
.public ResultTree setData(TreeNode... data) throws java.lang.IllegalStateException
fetchMode
is "basic"
or "local"
then the format of this data is exactly the same parentId
-linked list of tree nodes as documented on Tree.data
(when the modelType
is set to
"parent"
). If the fetchMode
is "paged"
then the format is extended to allow the
childCountProperty
to be set on folder nodes.
Providing an initial set of nodes in this way does not affect the behavior of the ResultTree in its loading of unloaded folders. An equivalent result is achieved if the first fetch from the server returns this same data.
If
fetchMode
is "paged"
then you may make folder-by-folder choices as to whether to use paging
for the childen of each folder. If you would like to use paging in a folder then you may include a partial list of that
folder's children with the data, provided that you set the childCountProperty
to the total number of
children. Otherwise you will need to include either all children of the folder or none of the children. Open folders
without any children provided will cause immediate, new fetches for the children, as usual.
Because the initial data
is treated exactly as though it were returned from the tree's first server fetch, the order of the initial data must
match the initial sort order of the TreeGrid displaying the data or, if no such sort is specified, the native storage
order on the server. For example, consider initial data containing n
records having the
parentId
"X"
, meaning they are all in the same folder. These n
records are the
records at indices 0
through (n - 1)
that are stored on the server under the parent node. If
the childCountProperty
set on the parent node indicates that there are m > n
total rows under
the parent node then the records at indices n
to (m - 1)
will be fetched from the server as
the user scrolls the additional rows into view.
Note : This is an advanced setting
setData
in class Tree
data
- New data value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdTree.setData(com.smartgwt.client.widgets.tree.TreeNode[])
,
TreeNode
,
Tree DataBinding
public TreeNode[] getData()
fetchMode
is "basic"
or "local"
then the format of this data is exactly the same parentId
-linked list of tree nodes as documented on Tree.data
(when the modelType
is set to
"parent"
). If the fetchMode
is "paged"
then the format is extended to allow the
childCountProperty
to be set on folder nodes.
Providing an initial set of nodes in this way does not affect the behavior of the ResultTree in its loading of unloaded folders. An equivalent result is achieved if the first fetch from the server returns this same data.
If
fetchMode
is "paged"
then you may make folder-by-folder choices as to whether to use paging
for the childen of each folder. If you would like to use paging in a folder then you may include a partial list of that
folder's children with the data, provided that you set the childCountProperty
to the total number of
children. Otherwise you will need to include either all children of the folder or none of the children. Open folders
without any children provided will cause immediate, new fetches for the children, as usual.
Because the initial data
is treated exactly as though it were returned from the tree's first server fetch, the order of the initial data must
match the initial sort order of the TreeGrid displaying the data or, if no such sort is specified, the native storage
order on the server. For example, consider initial data containing n
records having the
parentId
"X"
, meaning they are all in the same folder. These n
records are the
records at indices 0
through (n - 1)
that are stored on the server under the parent node. If
the childCountProperty
set on the parent node indicates that there are m > n
total rows under
the parent node then the records at indices n
to (m - 1)
will be fetched from the server as
the user scrolls the additional rows into view.
getData
in class Tree
Tree.getData()
,
TreeNode
,
Tree DataBinding
public ResultTree setDefaultIsFolder(java.lang.Boolean defaultIsFolder) throws java.lang.IllegalStateException
Nodes that have children or have the isFolderProperty
set to true will always be considered
folders. Other nodes will be considered folders or leaves by default according to this setting.
If
defaultIsFolder
is unset, the ResultTree will automatically set it to match the value of loadDataOnDemand
. This means that, when using
folder-by-folder load on demand (loadDataOnDemand:true
), by default a newly loaded node will be considered
to be a folder that has not loaded its children yet.
When not using folder-by-folder load on demand, by default a
newly loaded node is considered a leaf. If you set defaultIsFolder:true
explicitly, by default a newly
loaded node is considered to be a folder with no children.
See Tree.isFolder()
for details on how to explicitly mark nodes as folders
or leaves.
setDefaultIsFolder
in class Tree
defaultIsFolder
- New defaultIsFolder value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdTreeGrid.setLoadDataOnDemand(java.lang.Boolean)
public java.lang.Boolean getDefaultIsFolder()
Nodes that have children or have the isFolderProperty
set to true will always be considered
folders. Other nodes will be considered folders or leaves by default according to this setting.
If
defaultIsFolder
is unset, the ResultTree will automatically set it to match the value of loadDataOnDemand
. This means that, when using
folder-by-folder load on demand (loadDataOnDemand:true
), by default a newly loaded node will be considered
to be a folder that has not loaded its children yet.
When not using folder-by-folder load on demand, by default a
newly loaded node is considered a leaf. If you set defaultIsFolder:true
explicitly, by default a newly
loaded node is considered to be a folder with no children.
See Tree.isFolder()
for details on how to explicitly mark nodes as folders
or leaves.
getDefaultIsFolder
in class Tree
TreeGrid.getLoadDataOnDemand()
public ResultTree setDefaultNewNodesToRoot(java.lang.Boolean defaultNewNodesToRoot)
If set to true
, when a new node is added to this dataSource via DataSource.addData()
, with no explicit parentId, the node will be added as
a child of the root node of this result tree. Otherwise it will be ignored.
Similar logic applies to updated nodes
- if this property is true and the parentId of an updated
node is cleared, it will be moved to become a child of root, otherwise it will be dropped from the tree.
Note : This is an advanced setting
defaultNewNodesToRoot
- New defaultNewNodesToRoot value. Default value is falseResultTree
instance, for chaining setter callspublic java.lang.Boolean getDefaultNewNodesToRoot()
If set to true
, when a new node is added to this dataSource via DataSource.addData()
, with no explicit parentId, the node will be added as
a child of the root node of this result tree. Otherwise it will be ignored.
Similar logic applies to updated nodes
- if this property is true and the parentId of an updated
node is cleared, it will be moved to become a child of root, otherwise it will be dropped from the tree.
public ResultTree setDisableCacheSync(java.lang.Boolean disableCacheSync) throws java.lang.IllegalStateException
Note : This is an advanced setting
disableCacheSync
- New disableCacheSync value. Default value is falseResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getDisableCacheSync()
public ResultTree setDiscardParentlessNodes(java.lang.Boolean discardParentlessNodes) throws java.lang.IllegalStateException
Tree.parentIdField
which doesn't map to a valid parent node be
dropped? If set to false, for TreeGrid.loadDataOnDemand
:false trees, parentless nodes will be added as children of the root node - for TreeGrid.loadDataOnDemand
:true, they will be added as
children of the folder currently requesting children. This effectively allows nodes to be loaded into the current
(or root) folder without needing an explicit parentIdField
value
that matches the folder's ID or rootValue
for the resultTree.
Note: For
loadDataOnDemand:false
trees, if this property is unset at init time, it will default to true
if an explicit rootNode
has been specified. This ensures
that if the data tree retrieved from the server includes ancestors of the desired root-node we don't display them.
Otherwise this property always defaults to false.
Note : This is an advanced setting
setDiscardParentlessNodes
in class Tree
discardParentlessNodes
- New discardParentlessNodes value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getDiscardParentlessNodes()
Tree.parentIdField
which doesn't map to a valid parent node be
dropped? If set to false, for TreeGrid.loadDataOnDemand
:false trees, parentless nodes will be added as children of the root node - for TreeGrid.loadDataOnDemand
:true, they will be added as
children of the folder currently requesting children. This effectively allows nodes to be loaded into the current
(or root) folder without needing an explicit parentIdField
value
that matches the folder's ID or rootValue
for the resultTree.
Note: For
loadDataOnDemand:false
trees, if this property is unset at init time, it will default to true
if an explicit rootNode
has been specified. This ensures
that if the data tree retrieved from the server includes ancestors of the desired root-node we don't display them.
Otherwise this property always defaults to false.
getDiscardParentlessNodes
in class Tree
public ResultTree setFetchMode(FetchMode fetchMode) throws java.lang.IllegalStateException
fetchMode:"local" implies that local filtering will always be performed. See
keepParentsOnFilter
for additional filtering
details.
fetchMode:"basic" or "paged" implies that if search criteria change, the entire tree will be discarded and
re-fetched from the server. When retrieving the replacement tree data, the default behavior will be to preserve the
openState
for any nodes that the server returns which
were previously opened by the user. Note that this implies that if loadDataOnDemand
is enabled and the server returns only
root-level nodes, open state will be preserved only for root-level nodes, and children of open root-level nodes will be
immediately fetched from the server if they are not included in the server's initial response.
fetchMode:"paged"
enables paging for nodes that have very large numbers of children. Whenever the children of a folder are loaded, the
resultTree
will set DSRequest.startRow
and endRow
when requesting children from the DataSource, and will manage
loading of further children on demand, similar to how a ResultSet
manages paging for
lists. For a deeper discussion see the Paging large sets of children section of the TreeDataBinding
overview.
fetchMode
- New fetchMode value. Default value is "basic"ResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdsetLoadDataOnDemand(java.lang.Boolean)
,
setUseSimpleCriteriaLOD(boolean)
,
Tree DataBinding
,
Paging for Children Examplepublic FetchMode getFetchMode()
fetchMode:"local" implies that local filtering will always be performed. See
keepParentsOnFilter
for additional filtering
details.
fetchMode:"basic" or "paged" implies that if search criteria change, the entire tree will be discarded and
re-fetched from the server. When retrieving the replacement tree data, the default behavior will be to preserve the
openState
for any nodes that the server returns which
were previously opened by the user. Note that this implies that if loadDataOnDemand
is enabled and the server returns only
root-level nodes, open state will be preserved only for root-level nodes, and children of open root-level nodes will be
immediately fetched from the server if they are not included in the server's initial response.
fetchMode:"paged"
enables paging for nodes that have very large numbers of children. Whenever the children of a folder are loaded, the
resultTree
will set DSRequest.startRow
and endRow
when requesting children from the DataSource, and will manage
loading of further children on demand, similar to how a ResultSet
manages paging for
lists. For a deeper discussion see the Paging large sets of children section of the TreeDataBinding
overview.
getLoadDataOnDemand()
,
getUseSimpleCriteriaLOD()
,
Tree DataBinding
,
Paging for Children Examplepublic ResultTree setFirstPositionValue(java.lang.Integer firstPositionValue)
autoUpdateSiblingNodesOnDrag
is
in force, this is the value we will use to auto-update the position of a node when we cannot derive that value from the
existing value of a neighbor. This happens when a node is dropped into the very first position below a parent
(including the special case of the parent being previously empty)firstPositionValue
- New firstPositionValue value. Default value is 1ResultTree
instance, for chaining setter callspublic java.lang.Integer getFirstPositionValue()
autoUpdateSiblingNodesOnDrag
is
in force, this is the value we will use to auto-update the position of a node when we cannot derive that value from the
existing value of a neighbor. This happens when a node is dropped into the very first position below a parent
(including the special case of the parent being previously empty)public ResultTree setImplicitCriteria(Criteria implicitCriteria)
DataBoundComponent.initialCriteria
, setCriteria()
etc.implicitCriteria
- New implicitCriteria value. Default value is nullResultTree
instance, for chaining setter callspublic Criteria getImplicitCriteria()
DataBoundComponent.initialCriteria
, setCriteria()
etc.public ResultTree setKeepParentsOnFilter(java.lang.Boolean keepParentsOnFilter) throws java.lang.IllegalStateException
ResultTrees will default to fetchMode:"local"
whenever keepParentsOnFilter
is true, unless
fetchMode was explicitly set to "paged" (see below). This allows the filtering logic to fetch a complete tree of nodes
from the DataSource (or if loadDataOnDemand:true, a complete set of nodes under a given parent) and then filter the
resulting data locally on the client.
This means that the server does not need to implement special tree filtering logic to support looking up nodes that match the specified criteria as well as ancestor nodes that may not.
If
some criteria must be sent to the server in order to produce a valid tree of data, but
keepParentsOnFilter
is also required, the serverFilterFields
attribute may be used to specify a
list of field names that will be sent to the server whenever they are present in the criteria. Note that for the subset
of criteria applied to these fields, keepParentsInFilter
behavior will not occur without custom logic in
the DataSource fetch operation.
If FetchMode
is explicitly set to
"paged"
, it is not possible to implement keepParentsOnFilter
by local filtering. Support for
keepParentsOnFilter
for a paged ResultTree therefore also requires custom logic in the DataSource fetch
operation. To support this a developer must ensure that their fetch operation returns the appropriate set of nodes - all
nodes that match the specified criteria plus their ancestor nodes even if they do not match the specified criteria.
keepParentsOnFilter
- New keepParentsOnFilter value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdTree DataBinding
public java.lang.Boolean getKeepParentsOnFilter()
ResultTrees will default to fetchMode:"local"
whenever keepParentsOnFilter
is true, unless
fetchMode was explicitly set to "paged" (see below). This allows the filtering logic to fetch a complete tree of nodes
from the DataSource (or if loadDataOnDemand:true, a complete set of nodes under a given parent) and then filter the
resulting data locally on the client.
This means that the server does not need to implement special tree filtering logic to support looking up nodes that match the specified criteria as well as ancestor nodes that may not.
If
some criteria must be sent to the server in order to produce a valid tree of data, but
keepParentsOnFilter
is also required, the serverFilterFields
attribute may be used to specify a
list of field names that will be sent to the server whenever they are present in the criteria. Note that for the subset
of criteria applied to these fields, keepParentsInFilter
behavior will not occur without custom logic in
the DataSource fetch operation.
If FetchMode
is explicitly set to
"paged"
, it is not possible to implement keepParentsOnFilter
by local filtering. Support for
keepParentsOnFilter
for a paged ResultTree therefore also requires custom logic in the DataSource fetch
operation. To support this a developer must ensure that their fetch operation returns the appropriate set of nodes - all
nodes that match the specified criteria plus their ancestor nodes even if they do not match the specified criteria.
Tree DataBinding
public ResultTree setLinkDataAddOperation(java.lang.String linkDataAddOperation)
operationId
this ResultTree
should use when
performing add operations on its linkDataSource
.
Has no effect if this is not a multi-link tree
. Note,
this property wll be used by internal update operations when you drag-move or drag-reparent nodes in a multi-link tree.
Do not use it when adding records from application code by directly calling addData()
on the linkDataSource
; instead just use the regular
operationId
property in your add request. Also note, because this property is intended to allow your code
to influence the operationId used by internal methods, and those methods never directly update link data (moved and
re-parented links are always removed and then re-added), there is no corresponding
linkDataUpdateOperation
property.
linkDataAddOperation
- New linkDataAddOperation value. Default value is nullResultTree
instance, for chaining setter callspublic java.lang.String getLinkDataAddOperation()
operationId
this ResultTree
should use when
performing add operations on its linkDataSource
.
Has no effect if this is not a multi-link tree
. Note,
this property wll be used by internal update operations when you drag-move or drag-reparent nodes in a multi-link tree.
Do not use it when adding records from application code by directly calling addData()
on the linkDataSource
; instead just use the regular
operationId
property in your add request. Also note, because this property is intended to allow your code
to influence the operationId used by internal methods, and those methods never directly update link data (moved and
re-parented links are always removed and then re-added), there is no corresponding
linkDataUpdateOperation
property.
public ResultTree setLinkDataFetchMode(LinkDataFetchMode linkDataFetchMode) throws java.lang.IllegalStateException
multi-link tree
linkDataFetchMode
- New linkDataFetchMode value. Default value is "separate"ResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic LinkDataFetchMode getLinkDataFetchMode()
multi-link tree
public ResultTree setLinkDataFetchOperation(java.lang.String linkDataFetchOperation)
operationId
this ResultTree
should use when
performing fetch operations on its linkDataSource
.
Has no effect if this is not a multi-link tree
Note,
this value can be overridden by DSRequest.linkDataFetchOperation
when calling fetchData()
on the component (e.g. TreeGrid.fetchData
) directly from application code.
linkDataFetchOperation
- New linkDataFetchOperation value. Default value is nullResultTree
instance, for chaining setter callspublic java.lang.String getLinkDataFetchOperation()
operationId
this ResultTree
should use when
performing fetch operations on its linkDataSource
.
Has no effect if this is not a multi-link tree
Note,
this value can be overridden by DSRequest.linkDataFetchOperation
when calling fetchData()
on the component (e.g. TreeGrid.fetchData
) directly from application code.
public ResultTree setLinkDataRemoveOperation(java.lang.String linkDataRemoveOperation)
operationId
this ResultTree
should use when
performing remove operations on its linkDataSource
. Has no effect if this is not a multi-link
tree
. See linkDataAddOperation
for more
information on how this property is intended to be used.
linkDataRemoveOperation
- New linkDataRemoveOperation value. Default value is nullResultTree
instance, for chaining setter callspublic java.lang.String getLinkDataRemoveOperation()
operationId
this ResultTree
should use when
performing remove operations on its linkDataSource
. Has no effect if this is not a multi-link
tree
. See linkDataAddOperation
for more
information on how this property is intended to be used.
public ResultTree setLinkDataSource(DataSource linkDataSource) throws java.lang.IllegalStateException
dataSource
; linkDataSource
is only used
for
fetching and updating link information.
The linkDataSource
is an ordinary DataSource
that you implement
just like any other. However, for correct operation as a linkDataSource
, it
must have the following:
primaryKey field
. Like any dataSource, a
linkDataSource
is not fully functional without a primaryKey
fieldTree.parentIdField
Tree.idField
Tree.linkPositionField
Frame / \ Wheel Wheel / \ / \ Hub Tire Hub TireHere, the two wheels are the same assembly, so really it should look like this:
Frame | | Wheel / \ Hub TireNormal Smart GWT trees cannot model this arrangement accurately because this is not really a tree, it is a graph; trees do not contain multiple paths to a given node. The only way to handle this arrangement of nodes in a formal tree would be to make two copies of the "Wheel" node, at which point they are no longer the same thing. Either way, in a
TreeGrid
, we would have to visualise it like this:Frame Wheel Hub Tire Wheel Hub TireBut if we use copies so that the the two wheels are no longer the same thing, changing one of them will no longer change the other, which is a fundamental problem because in this scenario, the two wheels really are the same thing. Now, changing the name of the "Hub" in one "Wheel" would not change it in the other; adding a "Spokes" node to the second item would not also add it to the first. Drag-reordering child nodes in one "Wheel" would not re-order them in the other. All of these things are incorrect, because the two wheels are the same thing.
Multilink trees provide a way to handle this arrangement without physical copying of the duplicate nodes, preserving the sameness of them and thus fixing all the problems described above.
The node data for the above tree, simplified, would be a flat list something like this:
[ { id: 1, description: "Frame" }, { id: 2, description: "Wheel" }, { id: 3, description: "Hub" }, { id: 4, description: "Tire" } ]The link data would look like this:
[ { linkId: 1, parentId: 1, id: 2, position: 1 }, { linkId: 2, parentId: 2, id: 3, position: 1 }, { linkId: 3, parentId: 2, id: 4, position: 2 }, { linkId: 4, parentId: 1, id: 2, position: 2 } ]Or, if you were using
linkDataFetchMode
"single", you would combine
the node and link data into a single dataset like this:[ { id: 1, position: 0, description: "Frame" }, { parentId: 1, id: 2, position: 1, description: "Wheel", linkId: 1 }, { parentId: 2, id: 3, position: 1, description: "Hub", linkId: 2 }, { parentId: 2, id: 4, position: 2, description: "Tire", linkId: 3 }, { parentId: 1, id: 2, position: 2, description: "Wheel", linkId: 4 } ]
NOTE: It is also possible to create an unbound multilink tree - see Tree.linkData
.
linkDataSource
- New linkDataSource value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic DataSource getLinkDataSource()
dataSource
; linkDataSource
is only used
for
fetching and updating link information.
The linkDataSource
is an ordinary DataSource
that you implement
just like any other. However, for correct operation as a linkDataSource
, it
must have the following:
primaryKey field
. Like any dataSource, a
linkDataSource
is not fully functional without a primaryKey
fieldTree.parentIdField
Tree.idField
Tree.linkPositionField
Frame / \ Wheel Wheel / \ / \ Hub Tire Hub TireHere, the two wheels are the same assembly, so really it should look like this:
Frame | | Wheel / \ Hub TireNormal Smart GWT trees cannot model this arrangement accurately because this is not really a tree, it is a graph; trees do not contain multiple paths to a given node. The only way to handle this arrangement of nodes in a formal tree would be to make two copies of the "Wheel" node, at which point they are no longer the same thing. Either way, in a
TreeGrid
, we would have to visualise it like this:Frame Wheel Hub Tire Wheel Hub TireBut if we use copies so that the the two wheels are no longer the same thing, changing one of them will no longer change the other, which is a fundamental problem because in this scenario, the two wheels really are the same thing. Now, changing the name of the "Hub" in one "Wheel" would not change it in the other; adding a "Spokes" node to the second item would not also add it to the first. Drag-reordering child nodes in one "Wheel" would not re-order them in the other. All of these things are incorrect, because the two wheels are the same thing.
Multilink trees provide a way to handle this arrangement without physical copying of the duplicate nodes, preserving the sameness of them and thus fixing all the problems described above.
The node data for the above tree, simplified, would be a flat list something like this:
[ { id: 1, description: "Frame" }, { id: 2, description: "Wheel" }, { id: 3, description: "Hub" }, { id: 4, description: "Tire" } ]The link data would look like this:
[ { linkId: 1, parentId: 1, id: 2, position: 1 }, { linkId: 2, parentId: 2, id: 3, position: 1 }, { linkId: 3, parentId: 2, id: 4, position: 2 }, { linkId: 4, parentId: 1, id: 2, position: 2 } ]Or, if you were using
linkDataFetchMode
"single", you would combine
the node and link data into a single dataset like this:[ { id: 1, position: 0, description: "Frame" }, { parentId: 1, id: 2, position: 1, description: "Wheel", linkId: 1 }, { parentId: 2, id: 3, position: 1, description: "Hub", linkId: 2 }, { parentId: 2, id: 4, position: 2, description: "Tire", linkId: 3 }, { parentId: 1, id: 2, position: 2, description: "Wheel", linkId: 4 } ]
NOTE: It is also possible to create an unbound multilink tree - see Tree.linkData
.
public ResultTree setLinkDataSource(java.lang.String linkDataSource) throws java.lang.IllegalStateException
dataSource
; linkDataSource
is only used
for
fetching and updating link information.
The linkDataSource
is an ordinary DataSource
that you implement
just like any other. However, for correct operation as a linkDataSource
, it
must have the following:
primaryKey field
. Like any dataSource, a
linkDataSource
is not fully functional without a primaryKey
fieldTree.parentIdField
Tree.idField
Tree.linkPositionField
Frame / \ Wheel Wheel / \ / \ Hub Tire Hub TireHere, the two wheels are the same assembly, so really it should look like this:
Frame | | Wheel / \ Hub TireNormal Smart GWT trees cannot model this arrangement accurately because this is not really a tree, it is a graph; trees do not contain multiple paths to a given node. The only way to handle this arrangement of nodes in a formal tree would be to make two copies of the "Wheel" node, at which point they are no longer the same thing. Either way, in a
TreeGrid
, we would have to visualise it like this:Frame Wheel Hub Tire Wheel Hub TireBut if we use copies so that the the two wheels are no longer the same thing, changing one of them will no longer change the other, which is a fundamental problem because in this scenario, the two wheels really are the same thing. Now, changing the name of the "Hub" in one "Wheel" would not change it in the other; adding a "Spokes" node to the second item would not also add it to the first. Drag-reordering child nodes in one "Wheel" would not re-order them in the other. All of these things are incorrect, because the two wheels are the same thing.
Multilink trees provide a way to handle this arrangement without physical copying of the duplicate nodes, preserving the sameness of them and thus fixing all the problems described above.
The node data for the above tree, simplified, would be a flat list something like this:
[ { id: 1, description: "Frame" }, { id: 2, description: "Wheel" }, { id: 3, description: "Hub" }, { id: 4, description: "Tire" } ]The link data would look like this:
[ { linkId: 1, parentId: 1, id: 2, position: 1 }, { linkId: 2, parentId: 2, id: 3, position: 1 }, { linkId: 3, parentId: 2, id: 4, position: 2 }, { linkId: 4, parentId: 1, id: 2, position: 2 } ]Or, if you were using
linkDataFetchMode
"single", you would combine
the node and link data into a single dataset like this:[ { id: 1, position: 0, description: "Frame" }, { parentId: 1, id: 2, position: 1, description: "Wheel", linkId: 1 }, { parentId: 2, id: 3, position: 1, description: "Hub", linkId: 2 }, { parentId: 2, id: 4, position: 2, description: "Tire", linkId: 3 }, { parentId: 1, id: 2, position: 2, description: "Wheel", linkId: 4 } ]
NOTE: It is also possible to create an unbound multilink tree - see Tree.linkData
.
linkDataSource
- New linkDataSource value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String getLinkDataSourceAsString()
dataSource
; linkDataSource
is only used
for
fetching and updating link information.
The linkDataSource
is an ordinary DataSource
that you implement
just like any other. However, for correct operation as a linkDataSource
, it
must have the following:
primaryKey field
. Like any dataSource, a
linkDataSource
is not fully functional without a primaryKey
fieldTree.parentIdField
Tree.idField
Tree.linkPositionField
Frame / \ Wheel Wheel / \ / \ Hub Tire Hub TireHere, the two wheels are the same assembly, so really it should look like this:
Frame | | Wheel / \ Hub TireNormal Smart GWT trees cannot model this arrangement accurately because this is not really a tree, it is a graph; trees do not contain multiple paths to a given node. The only way to handle this arrangement of nodes in a formal tree would be to make two copies of the "Wheel" node, at which point they are no longer the same thing. Either way, in a
TreeGrid
, we would have to visualise it like this:Frame Wheel Hub Tire Wheel Hub TireBut if we use copies so that the the two wheels are no longer the same thing, changing one of them will no longer change the other, which is a fundamental problem because in this scenario, the two wheels really are the same thing. Now, changing the name of the "Hub" in one "Wheel" would not change it in the other; adding a "Spokes" node to the second item would not also add it to the first. Drag-reordering child nodes in one "Wheel" would not re-order them in the other. All of these things are incorrect, because the two wheels are the same thing.
Multilink trees provide a way to handle this arrangement without physical copying of the duplicate nodes, preserving the sameness of them and thus fixing all the problems described above.
The node data for the above tree, simplified, would be a flat list something like this:
[ { id: 1, description: "Frame" }, { id: 2, description: "Wheel" }, { id: 3, description: "Hub" }, { id: 4, description: "Tire" } ]The link data would look like this:
[ { linkId: 1, parentId: 1, id: 2, position: 1 }, { linkId: 2, parentId: 2, id: 3, position: 1 }, { linkId: 3, parentId: 2, id: 4, position: 2 }, { linkId: 4, parentId: 1, id: 2, position: 2 } ]Or, if you were using
linkDataFetchMode
"single", you would combine
the node and link data into a single dataset like this:[ { id: 1, position: 0, description: "Frame" }, { parentId: 1, id: 2, position: 1, description: "Wheel", linkId: 1 }, { parentId: 2, id: 3, position: 1, description: "Hub", linkId: 2 }, { parentId: 2, id: 4, position: 2, description: "Tire", linkId: 3 }, { parentId: 1, id: 2, position: 2, description: "Wheel", linkId: 4 } ]
NOTE: It is also possible to create an unbound multilink tree - see Tree.linkData
.
public ResultTree setLoadDataOnDemand(java.lang.Boolean loadDataOnDemand) throws java.lang.IllegalStateException
fetchMode
is "paged"loadDataOnDemand
- New loadDataOnDemand value. Default value is trueResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdTreeGrid.setLoadDataOnDemand(java.lang.Boolean)
,
setUseSimpleCriteriaLOD(boolean)
public java.lang.Boolean getLoadDataOnDemand()
fetchMode
is "paged"TreeGrid.getLoadDataOnDemand()
,
getUseSimpleCriteriaLOD()
public ResultTree setModelType(TreeModelType modelType)
TreeModelType
for
the available options and their implications. If the "parent" modelType is used, you can provide the initial
parent-linked data set to the tree via the Tree.data
attribute.
If the "children" modelType is used, you can provide the initial tree structure to the Tree via the Tree.root
attribute.
Note : This is an advanced setting
setModelType
in class Tree
modelType
- New modelType value. Default value is "parent"ResultTree
instance, for chaining setter callsTree.setData(com.smartgwt.client.widgets.tree.TreeNode[])
,
Tree.setRoot(com.smartgwt.client.widgets.tree.TreeNode)
,
Node Titles Examplepublic TreeModelType getModelType()
TreeModelType
for
the available options and their implications. If the "parent" modelType is used, you can provide the initial
parent-linked data set to the tree via the Tree.data
attribute.
If the "children" modelType is used, you can provide the initial tree structure to the Tree via the Tree.root
attribute.
getModelType
in class Tree
Tree.getData()
,
Tree.getRoot()
,
Node Titles Examplepublic ResultTree setProgressiveLoading(java.lang.Boolean progressiveLoading)
progressive loading mode
for this ResultTree.
The ResultTree will copy this setting onto the DSRequest
s that it issues, overriding
the OperationBinding- and DataSource-level settings, in cases where the use of progressive loading does not affect the
correctness of the tree's paging algorithm. This setting is applied automatically by DataBoundComponent
s that have their own explicit setting for progressiveLoading
.
Note: This
property only has an effect for fetchMode:"paged"
ResultTrees.
progressiveLoading
- New progressiveLoading value. Default value is nullResultTree
instance, for chaining setter callsDataSource.setProgressiveLoading(java.lang.Boolean)
,
OperationBinding.progressiveLoading
,
DSRequest.setProgressiveLoading(java.lang.Boolean)
,
Progressive Loading
public java.lang.Boolean getProgressiveLoading()
progressive loading mode
for this ResultTree.
The ResultTree will copy this setting onto the DSRequest
s that it issues, overriding
the OperationBinding- and DataSource-level settings, in cases where the use of progressive loading does not affect the
correctness of the tree's paging algorithm. This setting is applied automatically by DataBoundComponent
s that have their own explicit setting for progressiveLoading
.
Note: This
property only has an effect for fetchMode:"paged"
ResultTrees.
DataSource.getProgressiveLoading()
,
OperationBinding.progressiveLoading
,
DSRequest.getProgressiveLoading()
,
Progressive Loading
public ResultTree setResultSize(java.lang.Integer resultSize) throws java.lang.IllegalStateException
Applicable only with
fetchMode: "paged"
. When a paged ResultTree is asked for rows that have not yet been loaded, it will fetch
adjacent rows that are likely to be required soon, in batches of this size.
Note : This is an advanced setting
resultSize
- New resultSize value. Default value is 75ResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdTree DataBinding
public java.lang.Integer getResultSize()
Applicable only with
fetchMode: "paged"
. When a paged ResultTree is asked for rows that have not yet been loaded, it will fetch
adjacent rows that are likely to be required soon, in batches of this size.
Tree DataBinding
public ResultTree setSendNullParentInLinkDataCriteria(java.lang.Boolean sendNullParentInLinkDataCriteria) throws java.lang.IllegalStateException
multi-link tree
s only, should we send up the parentId
in fetch criteria if the criteria value is null? If
false, we remove the parentId
from the criteria when fetching link data
, if the criteria value is null
(as it will be by default when fetching the direct child nodes of the tree's root). Ignored for non-multiLink trees.
sendNullParentInLinkDataCriteria
- New sendNullParentInLinkDataCriteria value. Default value is trueResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getSendNullParentInLinkDataCriteria()
multi-link tree
s only, should we send up the parentId
in fetch criteria if the criteria value is null? If
false, we remove the parentId
from the criteria when fetching link data
, if the criteria value is null
(as it will be by default when fetching the direct child nodes of the tree's root). Ignored for non-multiLink trees.
public ResultTree setServerFilterFields(java.lang.String... serverFilterFields) throws java.lang.IllegalStateException
fetchMode:"local"
ResultTrees, this property lists field names that
will be sent to the server if they are present in the criteria. This property may be used to ensure a dataSource
receives the necessary criteria to populate a ResultTree's data, and also support keepParentsOnFilter
.
Note that for some
AdvancedCriteria it will not be possible to extract the subcriteria that apply to certain fields. See DataSource.splitCriteria()
for details on how
serverFilterFields-applicable subcriteria are extracted from the specified criteria for the tree.
serverFilterFields
- New serverFilterFields value. Default value is nullResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String[] getServerFilterFields()
fetchMode:"local"
ResultTrees, this property lists field names that
will be sent to the server if they are present in the criteria. This property may be used to ensure a dataSource
receives the necessary criteria to populate a ResultTree's data, and also support keepParentsOnFilter
.
Note that for some
AdvancedCriteria it will not be possible to extract the subcriteria that apply to certain fields. See DataSource.splitCriteria()
for details on how
serverFilterFields-applicable subcriteria are extracted from the specified criteria for the tree.
public ResultTree setUpdateCacheFromRequest(java.lang.Boolean updateCacheFromRequest) throws java.lang.IllegalStateException
DSResponse.data
is unset, should we integrate the submitted data values
(from the request) into our data-set?
Note : This is an advanced setting
updateCacheFromRequest
- New updateCacheFromRequest value. Default value is trueResultTree
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getUpdateCacheFromRequest()
DSResponse.data
is unset, should we integrate the submitted data values
(from the request) into our data-set?public ResultTree setUseSimpleCriteriaLOD(boolean useSimpleCriteriaLOD)
AdvancedCriteria
when sending the DSRequest
to load the children of a node in a loadDataOnDemand
or fetchMode:"paged"
ResultTree
. If the DSRequest.textMatchStyle
is not "exact", we normally convert the
simple criteria to an AdvancedCriteria
for correctness in matching the node name, but
setting this property to true
will allow that to be skipped for backcompat with older releases.
Note : This is an advanced setting
useSimpleCriteriaLOD
- New useSimpleCriteriaLOD value. Default value is falseResultTree
instance, for chaining setter callsTreeGrid.setAutoFetchTextMatchStyle(com.smartgwt.client.types.TextMatchStyle)
,
DataSource.setDefaultTextMatchStyle(com.smartgwt.client.types.TextMatchStyle)
public boolean getUseSimpleCriteriaLOD()
AdvancedCriteria
when sending the DSRequest
to load the children of a node in a loadDataOnDemand
or fetchMode:"paged"
ResultTree
. If the DSRequest.textMatchStyle
is not "exact", we normally convert the
simple criteria to an AdvancedCriteria
for correctness in matching the node name, but
setting this property to true
will allow that to be skipped for backcompat with older releases.TreeGrid.getAutoFetchTextMatchStyle()
,
DataSource.getDefaultTextMatchStyle()
public Tree applyFilter(Tree tree, Criteria criteria, TreeFilterMode filterMode, DataSource dataSource)
Default behavior is to call Tree.getFilteredTree()
to
obtain a new, filtered tree.
Override this method or Tree.getFilteredTree()
to implement your own client-side filtering behavior. Note that the original tree should not be
affected.
tree
- the source tree to be filteredcriteria
- the filter criteriafilterMode
- mode to use for filteringdataSource
- dataSource for filtering if the Tree does not already have onepublic Tree applyFilter(Tree tree, Criteria criteria, TreeFilterMode filterMode, DataSource dataSource, DSRequest requestProperties)
Default behavior is to call Tree.getFilteredTree()
to
obtain a new, filtered tree.
Override this method or Tree.getFilteredTree()
to implement your own client-side filtering behavior. Note that the original tree should not be
affected.
tree
- the source tree to be filteredcriteria
- the filter criteriafilterMode
- mode to use for filteringdataSource
- dataSource for filtering if the Tree does not already have onerequestProperties
- Request properties block. This allows developers to specify properties that would impact the filter such as DSRequest.textMatchStyle
public int compareCriteria(Criteria newCriteria, Criteria oldCriteria)
DataSource.compareCriteria()
to
determine whether new criteria is equivalent to the old criteria (returns 0) or not. See DataSource.compareCriteria()
for a full explanation of the default
behavior. The CriteriaPolicy
used is "dropOnChange".
Override this method or
DataSource.compareCriteria()
to implement your own
client-side filtering behavior.
newCriteria
- new filter criteriaoldCriteria
- old filter criteriaCriteriaPolicy
public int compareCriteria(Criteria newCriteria, Criteria oldCriteria, DSRequest requestProperties)
DataSource.compareCriteria()
to
determine whether new criteria is equivalent to the old criteria (returns 0) or not. See DataSource.compareCriteria()
for a full explanation of the default
behavior. The CriteriaPolicy
used is "dropOnChange".
Override this method or
DataSource.compareCriteria()
to implement your own
client-side filtering behavior.
newCriteria
- new filter criteriaoldCriteria
- old filter criteriarequestProperties
- dataSource request propertiesCriteriaPolicy
public void dataArrived(TreeNode parentNode)
parentNode
- The parentNode for which children were just loadedpublic TreeNode get(int pos)
get
in class RecordList
pos
- position of the node to getpublic Criteria getCombinedCriteria()
public AdvancedCriteria getCombinedCriteriaAsAdvancedCriteria()
public java.lang.String getOpenState()
TreeGridOpenState
object. This object can be passed to setOpenState()
or TreeGrid.setOpenState()
to open the same set of
folders within the tree's data (assuming the nodes are still present in the data).
TreeGridOpenState
setOpenState(java.lang.String)
public TreeNode[] getRange(int start, int end)
getRange
in class RecordList
start
- start positionend
- end position (NOT inclusive)public void invalidateCache()
Generally a ResultTree will detect and incorporate updates to the
DataSource that provides its records, but when this is not possible, invalidateCache()
allows manual cache
invalidation.
Components bound to this ResultTree will typically re-request the currently visible portion of the dataset, causing the ResultTree to re-fetch data from the server.
public void setChildren(TreeNode parent, java.util.List newChildren)
totalChildren
argument). The supplied array of children
may be null or empty to indicate there are none, but if present must be in the standard format as would be sent from the
server, as described by TreeDataBinding
. In particular, note that for a paged
ResultTree
, each child node:
Tree.childrenProperty
(but not via TreeNode.id
/TreeNode.parentId
linking) setChildren
in class Tree
parent
- parent of childrennewChildren
- children to be setTree.removeChildren(com.smartgwt.client.widgets.tree.TreeNode)
,
DataSource.updateCaches(com.smartgwt.client.data.DSResponse)
public void setChildren(TreeNode parent, java.util.List newChildren, java.lang.Integer totalChildren)
totalChildren
argument). The supplied array of children
may be null or empty to indicate there are none, but if present must be in the standard format as would be sent from the
server, as described by TreeDataBinding
. In particular, note that for a paged
ResultTree
, each child node:
Tree.childrenProperty
(but not via TreeNode.id
/TreeNode.parentId
linking) parent
- parent of childrennewChildren
- children to be settotalChildren
- number of total children (if not all have been provided as newChildren); only
allowed if pagingTree.removeChildren(com.smartgwt.client.widgets.tree.TreeNode)
,
DataSource.updateCaches(com.smartgwt.client.data.DSResponse)
public void setOpenState(java.lang.String openState)
TreeGridOpenState
object passed in. Used to restore previous state retrieved from the tree by a call to getOpenState()
.
openState
- Object describing the desired set of open folders.
See TreeGridOpenState
getOpenState()
,
TreeGridOpenState
public void unloadChildren(TreeNode node)
Tree.reloadChildren()
to reload the children of a folder, or Tree.removeChildren()
if you need to clear the cached children of a folder to add specific local data.unloadChildren
in class Tree
node
- folder in questionpublic java.lang.Boolean willFetchData(Criteria newCriteria)
This method can be used to determine whether TreeGrid.fetchData()
or TreeGrid.filterData()
will cause a server side fetch when passed a
certain set of criteria.
newCriteria
- new criteria to test.public static void setDefaultProperties(ResultTree resultTreeProperties)
Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.
resultTreeProperties
- properties that should be used as new defaults when instances of this class are createdSGWTProperties
public ResultTree setDataSource(DataSource dataSource) throws java.lang.IllegalStateException
DataSource
is this resultTree associated with?setDataSource
in class Tree
dataSource
- dataSource Default value is nullResultTree
instance, for
chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdDatabinding overview and related methods
,
DataSource fields Examplepublic DataSource getDataSource()
DataSource
is this resultTree associated with?getDataSource
in class Tree
Databinding overview and related methods
,
DataSource fields Examplepublic void setRootNode(com.google.gwt.core.client.JavaScriptObject rootNode) throws java.lang.IllegalStateException
rootValue
for this tree, allowing a component to navigate
a tree starting at a specific node. May be overridden via treeRootValue
for ResultTrees generated by a TreeGrid
component.
rootNode
- rootNode Default value is nulljava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic com.google.gwt.core.client.JavaScriptObject getRootNode()
rootValue
for this tree, allowing a component to navigate
a tree starting at a specific node. May be overridden via treeRootValue
for ResultTrees generated by a TreeGrid
component.