Eric H. Jung wrote:
Hi,
I have a number of template-driven, RDF-based <tree/> elements. They do
not specify 'dont-build-content'. I haven't found a way to
"automatically" save and restore the open/closed state of tree
containers, so unless someone can suggest one to me, I'm going to code
it manually.
My question is: what's the best way to maintain the list of open/closed
containers in an RDF file given that containers can be deleted and
moved? I was thinking of storing the subject of each open container in
a click callback:
tree.addEventListener("click", clickListener, true);
function clickListener(event) {
if (event.detail == 1) {
var row = {}, col = {}, childElt = {};
this.treeBoxObject
.getCellAt(event.clientX, event.clientY, row, col, childElt);
if (childElt.value == "twisty" && row.value > -1) {
// TODO: save open/close state
}
}
Any other ideas?
Eric,
First of all, the trees I use keep track of this without a single
additional line of code, but maybe I don't fully understand your
question. I wonder if you use ID's for your tree. Do you?
BTW: I would use: tree.treeBoxObject.view.isContainerOpen(row);
to get the open state of container ;)
Oh, and do you plan to add a tree observer?
var treeBuilderObserver = {
onToggleOpenState: function(aRow) {
do something here
}
}
tree.builder.addObserver(treeBuilderObserver);
tree.builder.removeObserver(treeBuilderObserver);
See also:
http://lxr.mozilla.org/seamonkey/source/content/xul/templates/public/nsIXULTemplateBuilder.idl
/HJ
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners