vitmalina / w2ui

UI widgets for modern apps. Data table, forms, toolbars, sidebar, tabs, tooltips, popups. All under 120kb (gzipped).
http://w2ui.com
MIT License
2.67k stars 728 forks source link

Tree-Like Grid #1819

Open NingMengMeng opened 5 years ago

NingMengMeng commented 5 years ago

Can Tree-Like Grid be loaded and all expanded by default?

mpf82 commented 2 years ago

No, still not possible, but you can easily do this in grid.onLoad -> event.done

        // expand all records with children recursively
        var do_expand = true;
        while ( do_expand ) {
            var records_count = grid.records.length;
            grid.records.forEach( ( rec ) => {
                if ( rec.w2ui && rec.w2ui.children ) {
                    grid.expand( rec.recid, true );
                }
            } );
            do_expand = ( records_count !== grid.records.length );
        }
        grid.refresh()

Notice the second parameter to grid.expand (noRefresh) that has recently been added in PR #2146 and that helps to speed this up.