row grouping with pagination
row grouping with pagination
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
This example describes the issue you are having and also a possible solution.
Allan
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
I missed that. However:
Isn't going to do anything though. The is a typo there - should be
bServerSide
orserverSide
.Allan