2015-09-16 31 views
-2

我试图使用jQuery的数据表下面jQuery的数据表的特殊表头

 <table id="tableau" class="display" width="100%" align="center"> 
      <thead> 
       <tr> 
        <th colspan="2"></th> 
        <th colspan="2"></th> 
        <th rowspan="2"></th> 
        <th colspan="2"></th> 
        <th rowspan="2"></th> 
       </tr> 
       <tr> 
        <th colspan="2"></th> 
        <th></th> 
        <th></th> 
        <th></th> 
        <th></th> 
       </tr> 
      </thead> 
      <tbody> 
      </tbody> 
     </table> 

这个独立工作很好,但,当我尝试用jQuery数据表不会在工作中显示的标题,使表所有。除表格标题外没有任何内容显示。

$(document).ready(function() { 
var table = $('#tableau').DataTable({ 
    "scrollY":   "500px", 
    "scrollCollapse": true, 
    "autoWidth":  true, 
    "paging":   false, 
    "processing":  false, 
    "info":    false, 
    "ordering":   false, 
    "searching":  false, 
    "data": [ 
      { 
       "ta": "ta", 
       "tb": "tb", 
       "tc": "tc", 
       "td": "td", 
       "te": "te", 
       "tf": "tf", 
       "tg": "tg", 
       "th": "th" 
      }, 
      { 
       "ta": "ta", 
       "tb": "tb", 
       "tc": "tc", 
       "td": "td", 
       "te": "te", 
       "tf": "tf", 
       "tg": "tg", 
       "th": "th" 
      }, 
    ], 
    "columns": [ 
     { 
      "data":    null, 
      "defaultContent": '' 
     }, 
     { "data":    "ta" }, 
     { "data":    null, 
      "defaultContent": '' 
     }, 
     { "data":    "tb" }, 
     { "data":    null, 
      "defaultContent": '' 
     }, 
     { "data":    null, 
      "defaultContent": '' 
     }, 
     { "data":    "tc" }, 
     { "data":    null, 
      "defaultContent": '' 
     } 
    ], 
}); 
+0

你已经尝试可以发布您的代码是什么? – soorapadman

回答

0

看看this demo

<table> 
    <thead> 
     <tr> 
      <td colspan="2">Test</td> 
      <td colspan="2">Test</td> 
      <td rowspan="2">Test</td> 
      <td colspan="2">Test</td> 
      <td rowspan="2">Test</td> 
     </tr> 
     <tr> 
      <td colspan="2">Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
      <td>Test</td> 
     </tr> 
    </tbody> 
</table> 
+0

谢谢,这项工作很好,但我忘记告诉你,我在这张表中使用jQuery数据表,并且它不能很好地工作 –

+0

你应该更新关于插件如何工作的问题..你如何使用它? –

+0

我刚刚用js和html代码更新了主题 –