Layout Subtree View

The layout subtree is used to reload content of some layout block via Ajax request.

Initialization

Layout update:

1
2
3
4
5
6
 layout:
     actions:
         - '@addTree':
             ...
             tree:
                 layout_block_id: ~

Add LayoutSubtreeView in block template:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 {% block _layout_block_id_widget %}
     <div id="block_id"
         data-page-component-module="oroui/js/app/components/view-component"
         data-page-component-options="{{ {
             view: 'oroui/js/app/views/layout-subtree-view',
             blockId : id,
             reloadEvents: ['reload-on-event'],
             restoreFormState: true
         }|json_encode }}"
         >
         {{ block_widget(block) }}
     </div>
 {% endblock %}

Or initialize in JavaScript:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 var LayoutSubtreeView = require('oroui/js/app/views/layout-subtree-view');
 var layoutSubtree = new LayoutSubtreeView({
     el: '#block_id',
     blockId: 'layout_block_id',
     reloadEvents: ['reload-on-event'],
     restoreFormState: true
 });

 //then call reload method
 layoutSubtree.reloadLayout();

 //or trigger reload event in other script
 var mediator = require('oroui/js/mediator');
 mediator.trigger('reload-on-event');