Hi Jenny,

the apply method from your defined property is only called when the 
property changes and not when the array content changes.

The solution for your problem depends on your use case. When you only 
need a single selection you can bind the array content with your property:
tree.bind("selection[0]",this,"selection");

For multi selection you have to listen to the array content changes, but 
in this case a own property is not needed:
tree.getSelection().addListener("change", this.myHandler, this);

Cheers,
Chris

Am 22.07.2011 12:17, schrieb Jenni Fer:
> Dear qooxdoo users,
> I would like to react to changes in the selection of a qx.ui.tree.VirtualTree 
> by binding the tree's selection property to another property of another class:
>
>    tree.bind("selection",this,"selection");
>
> Unfortunately this.applySelection() is never called when I select different 
> entries of the tree. What am I doing wrong? See below for the complete 
> standalone example.
> I would also like to use the Tree Controller together with VirtualTree. But 
> it seems only to be compatible with qx.ui.tree.Tree, or can you show me an 
> example how to make the Tree Controller work with a VirtualTree?
>
> Regards,
> Jenny
>
> code demonstrating the VirtualTree selection binding problem:
>
> qx.Class.define("tree.Application",{
>       extend : qx.application.Standalone,
>
>       properties:{
>               selection:{
>                       init: null,
>                       apply: "applySelection",
>                       event: "changeSelection"
>               }
>       },
>       members: {
>               applySelection: function(value){ //never called. why?
>                       alert("applySelection: "+value)
>               },
>               main: function(){
>                       this.base(arguments);
>                       var tree=this.createTree();
>                       tree.bind("selection",this,"selection");
>               },
>               createTree: function(){
>                       // initializes layout
>                       var container = new qx.ui.container.Composite(new 
> qx.ui.layout.HBox(20));
>                       this.getRoot().add(container, {top: 20, left: 20});
>
>                       // creates the tree
>                       var tree = new qx.ui.tree.VirtualTree(null, "name", 
> "children").set({
>                               width : 200,
>                               height : 400
>                       });
>                       container.add(tree);
>
>                       
> data={name:"Root",children:[{name:"Child",children:[]}]};
>                       var model = qx.data.marshal.Json.createModel(data, 
> true);
>                       tree.setModel(model);
>
>                       return tree;
>               }
>
>       }
> });


------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to