lorenzofox3 / flexy-layout

61 stars 19 forks source link

How to get full tree structure #13

Open muser83 opened 10 years ago

muser83 commented 10 years ago

How can I get the full tree structure?

Traversing in the blocks array of flexyLayout cannot get composite blocks (blocks with blocks inside)

muser83 commented 10 years ago

Is it possible to get all blocks in a ordered hierarchical structure?

lorenzofox3 commented 10 years ago

Hello,

Composite blocks are temp variables only created when moving a block and are not registered in the blocks array of the controller. If by composite you mean having a flexy layout inside another flexy layout, I would suggest you could write a directive or add a behavior to the existing one to parse the dom and find the proper block structure, (looking for div with class "block-content"unfortunatelly I have no time to do it at the moment.

But why do you want to access the whole structure programmaticallly ? you can have a look at the markup which is already somehow a treeview

mritzco commented 10 years ago

Hi,

I was looking for the same thing, getting the block structure would be useful to target specific elements in a children or different Flexy-layout (not accessible via the API), i.e.

( Vertical flexy-layout, with an horizontal one on the 2d row )

  A toolbar: [Toggle vp1][...]

| vp1 | vp2 | vp3 | vp4 | << This is a 2d flexy-layout

When from toolbar I access the API (directive > scope) there are only 2 blocks (2 rows), so I cannot close/change any vp# with: ctrl.moveBlockLength(index, false);

I end up modifying your collapse directive and adding an ugly hack to keep track of blocks and their controllers. It's working but I'm pretty sure it can be better done. Any advice would be appreciated!

http://plnkr.co/edit/r2gimFsT5XWt6Q5UWp0k?p=preview

Thanks