使用分页时选择所有行 [英] Select all rows while using pagination

查看:113
本文介绍了使用分页时选择所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子和全选复选框.我正在使用Bootstrap DataTable通过表进行分页,并且我希望SELECT ALL来选择页面中的所有行.那有可能吗?

I have a table and SELECT ALL checkbox. I am using Bootstrap DataTable to paginate through table and I would like SELECT ALL to select all rows across the pages. Is that possible and how?

我使用它,但是它仅在我返回该页面时才起作用,而不是在我第一次单击它时起作用.

I use this, but it works only when I return to that page, not when I first click on it.

$("#table").on( 'page.dt',   function () {
  if($('#select-all').is(":checked")){
    $(".bulk-checkbox").prop("checked", "true");
  }
  else {
    $(".bulk-checkbox").removeAttr('checked');
  }
 });

谢谢

推荐答案

好的,它是这样的:

$("#table_paginate").click(function () {
  if($('#select-all').is(":checked")){
    $(".bulk-checkbox").prop("checked", "true");
  }
  else {
    $(".bulk-checkbox").removeAttr('checked');
  }
});

这篇关于使用分页时选择所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆