Set "open" property of tree item.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Set "open" property of tree item.

alexander.volik
I have a tree with tree items described as

qx.Class.define("geoeat.customTreeNode", {
  extend : qx.ui.tree.TreeFolder,
  construct : function () {
    this.base(arguments);
    this.setChildren(new qx.data.Array());
  },
  properties : {
    name : {
      check: "String",
      init : "",
      event: "changeName"
    },
        id : {
      check: "Integer",
      event: "changeId"
    },
    children : {
      check: "qx.data.Array",
      event: "changeChildren"
    },
  }
});


And i want to programmatically open/close item
I'm trying do it such way:
this.treeController.getSelection().getItem(0).setOpen()
but this method does nothing.
Also method this.treeController.getSelection().getItem(0).getOpen()
returns "false" result for even item state (opened or closed). Why?
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

Christian Hagendorn
Administrator
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

alexander.volik
Christian Hagendorn wrote
setOpen is a method with a boolean parameter [1]. Please try:
this.treeController.getSelection().getItem(0).setOpen(true)
Of course, I use setOpen with boolean parameter, but there is no result of this
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

Christian Hagendorn
Administrator
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

alexander.volik
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

rsantiagopaz
works with
tree.getRoot().getChildren()[0].setOpen(true);

I think Item1 and tree.getRoot().getChildren()[0] are not reference to the same folder widget.
I think  the controller "reinterpret" treeData[0] like a model, and build other nodes. But I am not sure about this conclusion...
(sorry the english!)
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

MartinWittemann
Administrator
In reply to this post by alexander.volik
Hello Alexander,

I'm note really surprised that it does not work after taking a look at your code. Let me explain why:

You are mixing things up here a bit. The nodes you store in your treeData array are customTreeNode's. You pass these custom tree nodes to the controller as model. So the controller takes the data (and only the data) out of these objects and thats it. It is not using these objects as TreeFolders in the tree (visually) because it creates new widgets. It doesn't know that it should use these objects.

tree.getRoot().getChildren()[0].setOpen(true);

gets you the TreeFolder shown visually which then is opened as expected.
So subclassing the TreeFolder with your model is not really necessary. Subclassing qx.core.Object should be enough.

Regards,
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

alexander.volik
Hm... So, does getSelection() metod of qx.ui.tree.Tree and qx.data.controller.Tree return the same result?
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

MartinWittemann
Administrator
No, the one on the tree returns the tree folder and the controller method returns the selected models in a data array.

M.
Reply | Threaded
Open this post in threaded view
|

Re: Set "open" property of tree item.

MartinWittemann
Administrator
In reply to this post by alexander.volik
No, the one on the tree returns the tree folder and the controller method returns the selected models in a data array.

M.