gpt4 book ai didi

jquery - 如何在jquery数据表分页中选择记录

转载 作者:行者123 更新时间:2023-12-01 04:01:25 25 4
gpt4 key购买 nike

您好,当我单击全选(超链接)选项时,或者我想要将特定页面中的特定记录(使用复选框)发送到服务器类时,我尝试将 jquery 数据表中的所有记录发送到服务器类,但问题是当我单击表单提交按钮时即,导出 PDF 仅获取当前页面中的记录,即使在 jquery 数据表分页中的其他页面中选择了记录

为什么jquery数据表不同页面中选中的记录没有发送到java类

https://jsfiddle.net/4n5o3r3e/

<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="bas">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>

enter image description here

最佳答案

我希望我理解正确,您想在单击全选按钮时选择所有行并将所选行的计数发送到服务器。

这是一个 Working Demo

所以我使用数据表 API 做了这个(您将了解如何将计数发送到服务器):

$(document).ready(function() {
var table = $('#example').DataTable();

$("#selectall").click(function() {
var rows = table.rows({ 'search': 'applied' }).nodes();

debugger;
if($('input:checked', rows).length == rows.length){
$('input[type="checkbox"]', rows).prop('checked', false);
}
else{
$('input[type="checkbox"]', rows).prop('checked', true);
}


$('#dvcount').html($(rows).find("input:checked").length);

$("body").on("change","input",function() {

var rows = table.rows({ 'search': 'applied' }).nodes();
$('#dvcount').html($(rows).find("input:checked").length);

});

} );

关于jquery - 如何在jquery数据表分页中选择记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41933179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com