I'm trying to send all records with in a jQuery data table when I click select all(hyperlink) option or I want particular records in particular pages(using checkbox) to server class but the problem is when I click form submit button I.e Export PDF am getting only the records from current page even though records selected in other pages in jquery data table pagination.
<s:form id="downloadStudentDetailsForm" action="downloadStudentDetails" theme="css_xhtml" cssClass="form-horizontal">
<div class="dataTable_wrapper">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTS">
<thead>
<tr>
<th><a href="#" id="selectall">Select all</a></th>
<th>Student Name</th>
<th>Parent Phone</th>
<th>Parent Email</th>
<th>ReferenceID</th>
</tr>
</thead>
<tbody>
<s:iterator value="studentRecords">
<tr>
<td><s:checkbox name="students" cssClass="case chkPassport" fieldValue="%{studentname+' '+phone+' '+email+' '+ref}" /></td>
<td><s:property value="studentname" /></td>
<td><s:property value="phone" /></td>
<td><s:property value="email"></td>
<td><s:property value="ref" /></td>
</tr>
</s:iterator>
</tbody>
</table>
</div>
<div class="col-xs-1 ">
<s:submit cssClass="btn btn-success" value="Export to Excel" id="exl" action="downloadStudentsListINExcel" />
</div>
<div class="col-xs-3 ">
<s:submit cssClass="btn btn-danger" value="Export to PDF" id="pdf" action="downloadStudentsListInPDF" />
</div>
</s:form>
Script
$("#selectall").click(function() {
var rows = table.rows({ 'search': 'applied' }).nodes();
debugger;
if($('.case:checkbox:checked', rows).length == rows.length){
$('.case', rows).prop('checked', false);
}
else{
$('.case', rows).prop('checked', true);
}
$('#dvcount').html($(rows).find(".case:checkbox:checked").length);
$("body").on("change","input",function() {
var rows = table.rows({ 'search': 'applied' }).nodes();
$('#dvcount').html($(rows).find(".case:checkbox:checked").length);
});
} );
} );
I have given id for the check box then below code is working for me
See here: How can I select all checkboxes from all the pages in a jQuery DataTable
The answer should be the line: