row grouping with pagination

row grouping with pagination

Edleco01Edleco01 Posts: 7Questions: 2Answers: 0

My table is inside a form, and I am making a group of rows with two columns and it works very well for me.

$(window).on('shown.bs.modal', function() { 
    var collapsedGroups = {};
    var top = '';
    var tablePermiso;
    var permisostable = $('#permisostable').DataTable({
        "aProcessing" : true,
        "aServerSide" : true,
        "iDisplayLength": 10,
        'columnDefs' : [
        { 'visible': true, 'targets': [1,2]      }
        ],
        order: [[1, 'asc'], [2, 'asc']],
        rowGroup: {
            dataSrc: [ 1, 2 ],
            startRender: function(rows, groups, level){     
                var all;
                if(level === 0){
                    top = groups;
                    all = groups;
                }else{
                    if(!!collapsedGroups[top]){
                        return;
                    }
                    all = top + groups;
                }

                var collapsed = !!collapsedGroups[all];
                rows.nodes().each(function(r){
                    r.style.display = collapsed ? 'none' : ''; 
                });

                return $('<tr/>')
                .append('<td colspan="8"><b>'+groups+'('+rows.count()+')</b></td>')
                
                .attr('data-name', all)
                .toggleClass('collapsed', collapsed);
            }
        },
        "responsive": true,
        "bDestroy": true,
    });
    
    $('#permisostable tbody').on('click', 'tr.dtrg-start', function () {
        var name = $(this).data('name');
        collapsedGroups[name] = !collapsedGroups[name];
        permisostable.draw(false);
    });
});

My problem is when I send the form to js, ​​the formdata only brings me the elements of the current page of the table. How could I do to send all the existing elements in the form even if they are not visible in the current page of the table?

For example, if I click send on that side, it will only send me the elements on page 1, but not those on page 2, and this causes me serious inconvenience. But if I move to page two and hit send then it only sends me the elements on page two. Help me please.

Replies

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    This example describes the issue you are having and also a possible solution.

    Allan

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    You have server side processing enabled. This means that only the page being displayed is at the client. These are the only rows available for the client to access. If it doesn't cause processing issues you can turn off server side processing. Otherwise you will need to fetch the required data from the server. Similar to this FAQ discussing exporting data with server side processing.

    Kevin

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    I missed that. However:

    "aServerSide" : true,

    Isn't going to do anything though. The is a typo there - should be bServerSide or serverSide.

    Allan

Sign In or Register to comment.