Categories | Question details Back To List | ||
tree.setChildCalcMode: some suggestions Some suggestions regarding setChildCalcMode(): 1) Improve the documentation. What parameters does it take. 2) The child count appears in the node label as "[x]", as in: My node [3] When the tree is serialized, this notation becomes part of the data!!! If one stores this into the backing store, the next time you load from it, you'll get: My Node [3] [3] This behavior needs to be documented or, preferably, changed. tree.serialize() should strip this notation. As it is, I need to change my data layer to strip this off, which is non-trivial if I want the user to actually be able to use such notation IN THE DATA. It seems to me that the best way to handle this is to change the internal structure of the tree and display this information in a field next to the node label. This solution could be generalized to allow us to display userdata for each node, as well. Thanks, Joel Finkel Answer posted by Alex (support) on Feb 17, 2009 03:28 Please, try to use the following approach in order to don't include [x] to the serialization result: ... tree.setChildCalcMode("child"); ... The registerXMLEntity method allows to replace the value, which matches the 1st parameter, with the value defined in the second one. Answer posted by Joel Finkel on Feb 17, 2009 06:23 Alex, However, there is one problem. If the actual text in the tree is, for example: "Pogo Speaks [p. 10]" then the data are stored incorrectly. It seems to me that the child count is metadata, and I think it should be treated as such, and not intermingled with application data. So, I still think that it should be moved to a different internal tree structure. Thanks, Answer posted by Alex (support) on Feb 17, 2009 09:45 Unfortunately, currently there is no opportunity to do it. But it is possible to apply the replacement only for the last [x] part of the item text: tree.registerXMLEntity("\\[[^\\]]*\\]$",""); Moreover you can set another template for the calc value: tree.setChildCalcHTML(prefix,postfix); for example tree.setChildCalcHTML("(",")"); |