gpt4 book ai didi

jquery - 数据表布局问题 - 按钮和下拉菜单

转载 作者:太空宇宙 更新时间:2023-11-04 06:48:06 25 4
gpt4 key购买 nike

这是我当前在下图中的布局。我已经标记了图片以显示我想如何更改布局但无法弄清楚如何。 “新帖子”按钮下的所有内容(例如,按钮、分页、搜索、表格等)都是由 DATATABLES 生成的。我试图操纵 DOM 但没有成功。

这是我想要的布局:

Layout Problem

$(document).ready(function() {
$('#table-mh-admin-blog').DataTable({
dom: '<Blfr<t>ipl>',
buttons: [
'copy', 'excel', 'pdf', 'print'
],
select: true,
"order": [
[4, "asc"]
],
stateSave: true,
});
});
<div class="row ">
<h1>All Posts </h1>

<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_create/"><i class="fa fa-plus"></i> New Post</a>
<div>

<table id="table-mh-admin-blog" class="table table-condensed table-bordered table-striped table-hover" width="100%">
<thead>
<tr>
<th>Category</th>
<th>Author</th>
<th>Title / Post</th>
<th>Created</th>
<th>Updated</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Associations and Organizations</td>
<td>administrator</td>
<td>
<p> fffff</p>
<p>
fffff</td>
</p>
<td>2018-09-21 04:06:27</td>
<td>
N/A </td>
<td style="white-space:nowrap;">
<a class="btn btn-success btn-sm" href="/Blog_admin/blog_update/slug/fffff"><i class="fa fa-edit"></i></a>
<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_view_single/fffff"><i class="fa fa-eye"></i></a>
<a href="https://www.example.net/Blog_admin/blog_delete/id/190" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash-alt"></i></a>
</td>

</tr>
<tr>
<td>24354234234</td>
<td>administrator</td>
<td>
<p> test1</p>
<p>

asdasdasdasdasd richard testrtghfghf asdasd


</td>
</p>
<td>2018-09-29 05:37:09</td>
<td>
2018-10-08 22:48:30 </td>
<td style="white-space:nowrap;">
<a class="btn btn-success btn-sm" href="/Blog_admin/blog_update/slug/test1"><i class="fa fa-edit"></i></a>
<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_view_single/test1"><i class="fa fa-eye"></i></a>
<a href="https://www.example.net/Blog_admin/blog_delete/id/197" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash-alt"></i></a>
</td>

</tr>
<tr>
<td>24354234234</td>
<td>administrator</td>
<td>
<p> xxxxxxxxxxxxxxx</p>
<p>
</td>
</p>
<td>2018-10-06 07:12:59</td>
<td>
2018-10-08 22:37:32 </td>
<td style="white-space:nowrap;">
<a class="btn btn-success btn-sm" href="/Blog_admin/blog_update/slug/xxxxxxxxxxxxxxx"><i class="fa fa-edit"></i></a>
<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_view_single/xxxxxxxxxxxxxxx"><i class="fa fa-eye"></i></a>
<a href="https://www.example.net/Blog_admin/blog_delete/id/198" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash-alt"></i></a>
</td>

</tr>
</tbody>
</table>
</div>

</div>

<div class="row">
<div class="pagination-links">

</div>
</div>
<!-- end of row -->

感谢任何帮助。

最佳答案

你应该在你的 html 中引用数据表。你错过了它。我希望这就是你正在寻找的。

$(document).ready(function() {
$('#table-mh-admin-blog').DataTable({
dom: '<Blfr<t>ipl>',
buttons: [
'copy', 'excel', 'pdf', 'print'
],
select: true,
"order": [
[4, "asc"]
],
stateSave: true,
});
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<div class="row ">
<h1>All Posts </h1>

<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_create/"><i class="fa fa-plus"></i> New Post</a>
<div>

<table id="table-mh-admin-blog" width="100%">
<thead>
<tr>
<th>Category</th>
<th>Author</th>
<th>Title / Post</th>
<th>Created</th>
<th>Updated</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Associations and Organizations</td>
<td>administrator</td>
<td>
<p> fffff</p>
<p>
fffff</td>
</p>
<td>2018-09-21 04:06:27</td>
<td>
N/A </td>
<td style="white-space:nowrap;">
<a class="btn btn-success btn-sm" href="/Blog_admin/blog_update/slug/fffff"><i class="fa fa-edit"></i></a>
<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_view_single/fffff"><i class="fa fa-eye"></i></a>
<a href="https://www.example.net/Blog_admin/blog_delete/id/190" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash-alt"></i></a>
</td>

</tr>
<tr>
<td>24354234234</td>
<td>administrator</td>
<td>
<p> test1</p>
<p>

asdasdasdasdasd richard testrtghfghf asdasd


</td>
</p>
<td>2018-09-29 05:37:09</td>
<td>
2018-10-08 22:48:30 </td>
<td style="white-space:nowrap;">
<a class="btn btn-success btn-sm" href="/Blog_admin/blog_update/slug/test1"><i class="fa fa-edit"></i></a>
<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_view_single/test1"><i class="fa fa-eye"></i></a>
<a href="https://www.example.net/Blog_admin/blog_delete/id/197" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash-alt"></i></a>
</td>

</tr>
<tr>
<td>24354234234</td>
<td>administrator</td>
<td>
<p> xxxxxxxxxxxxxxx</p>
<p>
</td>
</p>
<td>2018-10-06 07:12:59</td>
<td>
2018-10-08 22:37:32 </td>
<td style="white-space:nowrap;">
<a class="btn btn-success btn-sm" href="/Blog_admin/blog_update/slug/xxxxxxxxxxxxxxx"><i class="fa fa-edit"></i></a>
<a class="btn btn-primary btn-sm" href="https://www.example.net/Blog_admin/blog_view_single/xxxxxxxxxxxxxxx"><i class="fa fa-eye"></i></a>
<a href="https://www.example.net/Blog_admin/blog_delete/id/198" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash-alt"></i></a>
</td>

</tr>
</tbody>
</table>
</div>

</div>

<div class="row">
<div class="pagination-links">

</div>
</div>



<!-- end of row -->

关于jquery - 数据表布局问题 - 按钮和下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53112697/

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