Hello,

I'm using the binding features on trees with delegate options in order to
manage specific models (PS: thanks Martin for your comment about the bug
2632 - I didn't catch directly how to use the delegate options (great
feature by the way :-) ).

I'm not sure if it is a bug - maybe I'm completely mistaken - but the
following code seems not work :

var tree = new qx.ui.tree.Tree();
tree.controller = new qx.data.controller.Tree(null,tree);

var model = qx.data.marshal.Json.createModel(datas); // datas = js object

var delegate = 
{
        createItem: function()
        {
                var treeItem = new qx.ui.tree.TreeFolder();
                treeItem.setUserData('homepage',new qx.ui.basic.Image());
                treeItem.addWidget(treeItem.getUserData('homepage'));
                treeItem.addLabel("");
                treeItem.addWidget(new qx.ui.core.Spacer(), {flex: 1});
                treeItem.setUserData('public',new qx.ui.basic.Image());
                treeItem.addWidget(treeItem.getUserData('public'));
                treeItem.setUserData('in_menu',new qx.ui.basic.Image());
                treeItem.addWidget(treeItem.getUserData('in_menu'));
                treeItem.setUserData('translated',new qx.ui.basic.Image());
                treeItem.addWidget(treeItem.getUserData('translated'));
                treeItem.setOpen(true);
                
                return treeItem;
        },
        configureItem: function(item)
        {
                item.getUserData('public').setWidth(80);
                item.getUserData('in_menu').setWidth(70);
                item.getUserData('translated').setWidth(40);
        }
};
                
tree.controller.setDelegate(delegate);
tree.controller.setModel(model);

...


It throws an error at runtime because when _setConfigureItem() is called, it
is looking for the root of the tree but it of course doesn't exists yet at
the first step: the error is "this.getTarget().getRoot() is null".

I can manage it by adding a dummy root to my tree at init stage using the
createItem function but maybe it would be more intuitive to modify the
_setConfigureItem() function by setting the targeted treeItem as root of the
tree if it doesn't yet exists ?

Regards,

BenoƮt.
-- 
View this message in context: 
http://n2.nabble.com/bug-in-qx-data-controller-Tree-tp4093385p4093385.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to