当我单击全选(超链接)选项时,或者我想要将特定页面中的特定记录(使用复选框)发送到服务器类时,我试图将 jQuery 数据表中的所有记录发送到服务器类,但问题是当我单击表单提交按钮时,即导出PDF 仅获取当前页面中的记录,即使在 jquery 数据表分页中的其他页面中选择了记录。
<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);
});
} );
} );
看这里:如何从 jQuery DataTable 中的所有页面中选择所有复选框
答案应该是这样一行:
var allPages = table.fnGetNodes();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)