DataTable Row Toggle Option

后端 未结 3 1975
醉话见心
醉话见心 2021-02-04 18:46

My Issue:

I am working on a project which is related to DataTableJS. I need a row grouping feature and It\'s separated with grouped rows. Just I want to

3条回答
  •  青春惊慌失措
    2021-02-04 19:06

    First I tried https://datatables.net/examples/api/row_details.html, but it was not rendered as I expected.

    Therefore I implemented it myself:

    JS

    $(document).ready(function () {
    ......
    $('.datatable-header-footer').on('draw.dt', function () {
                    bindRowToggle();
                });
    
                $('.datatable-header-footer').on('processing.dt', function () {
                    bindRowToggle();
                });
    
                $('.datatable-header-footer').on('search.dt', function () {
                    bindRowToggle();
                });
    
                bindRowToggle();
            });
    
            function bindRowToggle() {
                $('tr.parentOrder').click(function () {
                    $(this).nextAll(':lt(2)').toggle();
                });
            }
    

    CSS

    .parentOrder {
    
    }
    
    .childOrder {
        display: none;
    }           
    

    HTML

    
    ...
    

    提交回复
    热议问题