Should have searched the mailing list archives before sending.

I ran into Martin Wittemann's advice on using the delegate's bindItem
method so my code now looks like this:

           var controller = new qx.data.controller.Tree(null, tree,
"contents", "name");
           controller.setDelegate({
             bindItem : function(controller, item, id) {
               controller.bindProperty("name", "label", null, item, id);
               controller.bindProperty("contents.length", "appearance", {
                                         converter : function(data) {
                                           return data > 0 ?
"tree-folder" : "tree-file";
                                         }
                                       }, item, id);
             }
           });
           controller.setModel(model);

Everything works! Thanks!

-deech

On Thu, Jul 28, 2011 at 11:07 PM, aditya siram <[email protected]> wrote:
> Hi all,
> I'm using qx.data.controller.Tree to bind the nodes of a tree to some
> json which contains two types of structures, for folders:
> {
>  "type" : "folder",
>  "name" : "FOLDER1",
>  "contents" : []
> }
> and files:
> {
>  "type" : "file",
>  "name" : "file1",
>  "contents" : "hello world"
> }
>
> However, the controller only seems to take keys for "label" and
> "children" and makes every tree node a qx.ui.tree.TreeFolder.
>
> I'd like the "_createItem" method in qx.data.controller.Tree to create
> a qx.ui.tree.TreeFile if the "model.getType()" is "file"  and a
> qx.ui.tree.TreeFolder if the "model.getType()" is "folder".
>
> Is there some way to do this without rewriting/subclassing large
> chunks of the qx.data.controller.Tree class?
>
> -deech
>

------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to