Problem with Layout and Accordion

When I use function collapse() and expand() of cells in layout I have problem.

see examples attached.
first example problem when open cells “b”, accordion error.
second example problem in cells “b” collapse, no border and no title.

You can help me?

I have problem to send my files with suite, error:
The attachment’s file size is too large, the maximum upload size is 2 MB.
Please note this is set in php.ini and cannot be overridden.
Test.zip (1.88 MB)

Hi

1st demo) try to attach accordion into expanded cell (once after expand on demand via event)
2nd demo) byt the default layout automatically hides hides borders if acc attached and there is no ability to collapse cell by click, just use layout.cell(id)._showBorders() and _hideBorders()

Thanks Andrei per help me!

Solution:

    <script>
        var layout;
        
        window.onload = function(){
            layout = new dhtmlXLayoutObject(document.body, "2U");
            layout.cells('a').hideArrow();
            layout.cells('b').hideArrow();
            layout.cells('b').setWidth('300');
            
            layout.cells('b').attachObject('test');
            var layout2 = new dhtmlXLayoutObject("test", "3L");
            
            layout.cells('b').collapse();
            
            layout.cells("a").attachHTMLString(
                '<input type="button" value="Open b" onclick="Open()" />'+
                '<input type="button" value="Close b" onclick="Close()" />'
            );
        };
        
        function Open() {
            layout.cells('b').expand();
            layout.cells('b')._hideBorders();
            var accordion = layout.cells('b').attachAccordion(
                { 
                    items: [
                        {
                            id: '1',
                            text: 'One'
                        },
                        {
                            id: '2',
                            text: 'Two'
                        },
                        {
                            id: '3',
                            text: 'Three'
                        }                        
                    ]
                }
            );
        }
        
        function Close() {
            layout.cells('b')._showBorders();
            layout.cells('b').showHeader();
            layout.cells('b').collapse();
        }
    </script>

:smiley:

something like, but your acc will reattached each open time

you need:

  1. move var accordion to global scope and add code like:
    if (accordion == null) {
    accordion = layout.cells(‘b’).attachAccordion(…);
    }

  2. or without moving variable:
    if (!(layout.cells(“b”).getAttachedObject() instanceof dhtmlXAccordion)) {
    var accordion = layout.cells(‘b’).attachAccordion(…);
    }