jQuery DataTables colReorder插件realtime: false设置不生效问题求助
jQuery DataTables colReorder插件realtime: false设置不生效问题求助
你好呀,最近做项目时遇到了一个jQuery DataTables的小问题,想请教下大家!
我在使用jQuery DataTables搭配colReorder扩展时,明明配置了realtime: false,但这个设置好像完全没起作用。我原本的预期是:只有当拖放列完成、松开鼠标的那一刻,列的排序才会更新生效;可实际情况却是,拖动列的过程中,表格的列位置就会实时跟着变化,和我想要的效果完全相反。
下面是我目前的代码片段(部分内容有省略):
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>DataTables Example</title> <script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script> <link href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.css" rel="stylesheet"> <link href="https://cdn.datatables.net/responsive/3.0.2/css/responsive.dataTables.css" rel="stylesheet"> <script src="https://cdn.datatables.net/2.0.8/js/dataTables.js"></script> <script src="https://cdn.datatables.net/colreorder/2.0.3/js/dataTables.colReorder.js"></script> </head> <body> <table id="example" class="display" style="width:100%"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th> <th>Age</th> <th>Start date</th> <th>Salary</th> </tr> </thead> <tbody> <tr> <td>Tiger Nixon</td> <td>System Architect</td> <td>Edinburgh</td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> </tr> <!-- 更多示例数据省略 --> </tbody> </table> <script> $(document).ready(function() { $('#example').DataTable({ colReorder: { realtime: false } }); }); </script> </body> </html>
我已经确认colReorder插件是正常引入的,表格的其他功能都能正常使用,唯独这个realtime参数的配置没有达到预期效果。有没有朋友遇到过类似的问题?或者是不是我在配置的时候哪里出错了?麻烦大家帮我看看,非常感谢!
备注:内容来源于stack exchange,提问作者Akhil khandelwal
相关产品推荐
相关产品推荐

