Good morning Benoît,
no i get what you are planing to do. Thanks for the detailed
description. I guess the best way to load the tree structure on demand
is to always keep the binding to the initial model and just add the
models loaded after the initial model to the initial model:
initial model (m1):
a
- a1
- a2
now you click on a1 and load that (m2):
a1
- a11
- a12
You have two different models but you can just grab the kids of the
second model and set them in the first model.
m1.getKids()[0].setKids(m2.getKids());
That should keep the whole structure and just add the kids.
The list binding could always take the kids of the current selection.
treeController.bind("selection.kids", listController, "model");
Have you seen the qooxdoo feed reader example? This is based on the
data binding features as well. Perhaps you can get some ideas from
that code.
Best,
Martin
Am 25.07.2009 um 12:06 schrieb benco:
>
> Hello Martin,
>
> Sorry for the lack of precise informations. OK, I explain :). I work
> on a
> sort of file manager. It has two parts : a tree and a list (like any
> file
> manager window). In order to manage and retreive all the relevant
> datas, I
> use a store and link the model to the two widget controllers (the
> tree and
> the list).
>
> My model definition (could evolve but it follows mainly the examples
> on the
> demo page):
>
> {tree:{name:"",kids:[]},currentfolder:[{name:"",type:"folder|
> file"},...]}
>
> In an initialisation step, the tree must load the first and second
> level. In
> the following steps, I delete this behaviour because the goal is to
> display
> the currentfolder in the list and populate the tree with additional
> sub-folders when we select a tree node.
>
> But I don't know how to add the new sub-folders in the tree (except
> if I
> worked without the new binding features). When I select a treenode,
> the json
> store is reloaded with additional parameters. The result is in the
> same kind
> of the above described model except that {tree:{name:"",kids:[]}} only
> concerns the selected folder in the tree. So, as the name doesn't
> change (I
> don't plan to manage concurrence yet), I only need to bind the kids
> of the
> model store to the kids of the selection in the tree controller.
>
> But "this.store.bind('model.tree.kids', this.tree.controller,
> 'selection[0].kids'))" seems not to work. Anyway, the content isn't
> refreshed (I don't notice any add). And furthermore, the previous
> selected
> treenode isn't anymore selected after the bind assignment.
>
> Regarding my second question, I already noticed that it was
> qx.data.Array
> based. In fact you can consider it as a complement to my first
> question. I
> tried to do this kind of operation as the
> "this.store.bind('model.tree.kids', this.tree.controller,
> 'selection[0].kids'))" seemed not work:
>
> this.store.addListener("loaded", function(ev)
> {
>
> ...
>
> ...
>
> var target = this.tree.controller.getSelection();
> target.splice(0,1,ev.getTree());
>
> (or)
>
> var target = this.tree.controller.getSelection();
> target.setName(ev.getTree().getName());
> target.setKids(ev.getTree().getKids());
>
> ...
>
> }, this);
>
>
> I hope it's more clear for you :). Have a nice weekend!
>
> Best,
>
> Benoît.
>
>
> Martin Wittemann wrote:
>>
>> Hello Benoît,
>>
>> I have to admit that I don't get your use case right. You want to use
>> "model.tree" on the first load as model for the tree controller and
>> on
>> the second load, you want to use "model.tree.kids"? Do you want to
>> set
>> the selection with the second bind? :
>>> this.store.bind('model.tree.kids', this.tree.controller,
>>> 'selection[0].kids')); // this would'nt work
>>
>> Because thats what the code tries to do.
>>
>> Perhaps you could tell me what you want to achieve with the code?
>> Maybe i can help you more if I know what you want to do.
>>
>> To your second question: You can just change the model and the data
>> binding will populate the the tree. As the model is a set of qooxdoo
>> objects with data arrays, you can just manipulate these model objects
>> and that should do the job. :)
>>
>> Best,
>> Martin
>>
>>
>> Am 24.07.2009 um 16:08 schrieb benco:
>>
>>>
>>> Hello,
>>>
>>> I'm a bit stuck and I really need some help here.
>>>
>>> I'm working on a Tree that can be loaded progressively on deploy and
>>> selection events. I also would like using the new binding features
>>> with that
>>> tree (namely the Tree Controller and the Json Store).
>>>
>>> The problem is I don't know how to manage the bindings correctly.
>>>
>>> In the first step (first launch), I bind the store with the tree
>>> controller.
>>> Then, the behaviour changes. The store should be binded to the tree
>>> controller "selection[0]". I really don't know how to do this in a
>>> simple
>>> way.
>>>
>>> If it's not possible ... never mind (I'll use the default tree
>>> behaviours
>>> and functions). But It would be useful and cool.
>>>
>>> Here's a code example:
>>>
>>> this.tree.controller = new qx.data.controller.Tree(null,
>>> this.browser.tree,
>>> "kids", "name");
>>>
>>> this.store = new qx.data.store.Json();
>>>
>>> this.tree.bindId =
>>> store.bind('model.tree',this.tree.controller,'model');
>>>
>>> this.store.addListener("loaded", function(ev)
>>> {
>>> // first loading
>>> if (this.tree.bindId)
>>> {
>>> this.store.removeBinding(this.tree.bindId);
>>> this.tree.bindId=null;
>>>
>>> var root = this.tree.getRoot();
>>> if (root)
>>> {
>>> this.tree.addToSelection(root);
>>> root.setOpen(true);
>>> }
>>> }
>>> else
>>> {
>>> this.store.bind('model.tree.kids',this.tree.controller,
>>> 'selection[0].kids')); // this would'nt work
>>> }
>>> }, this.browser);
>>>
>>> Furthermore, I'd like to know how I can complete/populate a partial
>>> zone of
>>> a model in the tree controller by new additional datas without
>>> resetting it
>>> completely... Any Ideas ?
>>>
>>> Thanks in advance,
>>>
>>> Best,
>>>
>>> Benoît.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Progressive-Tree-on-selection-and-or-deployement-%2B-the-new-binding-features-tp24645160p24645160.html
>>> Sent from the qooxdoo-devel mailing list archive at Nabble.com.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Progressive-Tree-on-selection-and-or-deployement-%2B-the-new-binding-features-tp24645160p24656522.html
> Sent from the qooxdoo-devel mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel