【问题标题】:Adjust Prev and Next button to the corners of Table将 Prev 和 Next 按钮调整到表格的角落
【发布时间】:2018-06-08 01:44:29
【问题描述】:

我有一个数据表,在表的顶部和底部有一个 PreviousNext 按钮。

我的问题是如何调整左角的Previous 按钮和右角的Next 按钮,而不管表格宽度如何,现在这是我的sDom

"sDom": '<"top"ifp<"clear">>rt<"bottom"p>',

tysm

【问题讨论】:

  • 如果没有看到您正在使用的 HTML 和 CSS,我认为不可能给您任何指导。
  • 目前我可以给你的唯一代码是datables下的代码不再添加任何代码因为我不知道从哪里开始,非常抱歉

标签: jquery html css datatables


【解决方案1】:

一种方法是为 Prev 和 Next 创建自定义按钮;然后将其附加到您的 DataTables 的 dom

var table = $('#example').DataTable({
  pagingType: "simple",
  sDom: '<"top"if<"#top"><"clear">>rt<"#bottom">'
});

var cust_btn = '<div class="row custom_btn"><div class="col-xs-6 text-left"><div><button type="button" class="btn btn-default prev">Prev</button></div></div><div class="col-xs-6 text-right">   <div><button type="button" class="btn btn-default next">Next</button> </div></div></div>'
$('#bottom').append(cust_btn);
$('#top').append(cust_btn);


$('.next').on('click', function() {
  table.page('next').draw('page');
});

$('.prev').on('click', function() {
  table.page('previous').draw('page');
});

在按钮上附加一个点击事件,然后使用 DataTables 的页面 API。 Fiddle供参考。

【讨论】:

  • 其实我就是这么做的。我创建了自定义控件,它运行良好,没有考虑如何移动客户 prevnext 反正thnx
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-04
  • 2016-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多