简体   繁体   English

创建具有固定标头和可调整大小列的响应式可排序引导表

[英]Creating a Responsive, Sortable Bootstrap Table with Fixed Headers and Resizable Columns

I am attempting to create a Sortable Table (dataTables) with both Fixed Headers (floatThead) and Resizable columns (jquery-resizable-columns) using Bootstrap 3 w/ responsive tables. 我正在尝试使用Bootstrap 3 w /响应表创建一个带有Fixed Headers(floatThead)和Resizable列(jquery-resizable-columns)的可排序表(dataTables)。 So far I am able to get it to do two things at once, but not three. 到目前为止,我能够让它同时做两件事,但不是三件事。 That is, either Resizable Columns and Sortable, or Sortable with Fixed Headers, etc. When I go up to three pieces of JS, things stop working. 也就是说,可调整大小的列和可排序,或者可以使用固定标题排序等。当我最多使用三个JS时,事情就会停止工作。

I've got a little JSFiddle going here: http://jsfiddle.net/cpJE2/2/ 我有一个小JSFiddle在这里: http//jsfiddle.net/cpJE2/2/

$(function(){
     $("table").resizableColumns();
     $('#example').dataTable({
        "bPaginate": false,
        "bLengthChange": false,
        "bFilter": false,
        "bSort": true,
        "bInfo": false,
        "bAutoWidth": false
        });
     $("table.table").floatThead();
 });

Any thoughts on what could be causing the conflict here or thoughts on a workaround? 关于什么可能导致这里的冲突或想法解决方法的任何想法? I know there are similar questions out there, but none, I believe, that are this specific. 我知道那里有类似的问题,但我相信没有,这是具体的。 I basically need to get as much table function as possible. 我基本上需要获得尽可能多的表函数。 Any help would be very appreciated. 任何帮助将非常感激。

SOLUTION

Using jQuery DataTables 1.10.9 with Bootstrap styling, FixedHeader and Responsive extensions and unofficial ColResize plug-in you can create responsive, sortable table with Bootstrap styling, fixed headers and resizable columns using the code below: 使用带有Bootstrap样式,FixedHeader和Responsive扩展以及非官方ColResize插件的 jQuery DataTables 1.10.9,您可以使用以下代码创建具有Bootstrap样式,固定标题和可调整大小列的响应式可排序表:

var table = $('#example').DataTable({
   dom:
      "<'row'<'col-sm-6'l><'col-sm-6'f>>" +
      "<'row'<'col-sm-12'Ztr>>" +
      "<'row'<'col-sm-5'i><'col-sm-7'p>>",
   fixedHeader: true,
   responsive: true
});

Please note that ColResize plug-in doesn't fully support FixedHeader, see this issue on GitHub . 请注意, ColResize插件并不完全支持FixedHeader,请参阅GitHub上的此问题

DEMO DEMO

See this jsFiddle for code and demonstration. 有关代码和演示,请参阅此jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM