2017-11-10 31 views
1

我正在使用Datatable.net框架的表。datatables.net:如何使用数据表中的响应加复选框?

我的问题是这个我想要在同一个数据表中的2个东西是响应和第二个是复选框。

这是剧本我使用这个

$(document).ready(function() { 
    $('#example').DataTable({ 
     responsive: true, 
     columnDefs: [ { 
      orderable: false, 
      className: 'select-checkbox', 
      targets: 0 
     } ], 
     select: { 
      style: 'os', 
      selector: 'tr' 
     }, 
     order: [[ 1, 'asc' ]] 
    }); 
}); 

这是HTML我使用。

<table id="example" class="display" width="100%" cellspacing="0"> 
    <thead> 
     <tr> 
      <th></th> 
      <th>Name</th> 
      <th>Position</th> 
      <th>Office</th> 
      <th>Age</th> 
      <th>Salary</th> 
     </tr> 
    </thead> 
    <tfoot> 
     <tr> 
      <th></th> 
      <th>Name</th> 
      <th>Position</th> 
      <th>Office</th> 
      <th>Age</th> 
      <th>Salary</th> 
     </tr> 
    </tfoot> 
    <tbody> 
     <tr> 
      <td></td> 
      <td>Tiger Nixon</td> 
      <td>System Architect</td> 
      <td>Edinburgh</td> 
      <td>61</td> 
      <td>$320,800</td> 
     </tr> 
    </tbody> 
</table> 
+0

你加它来自于与数据表中的 –

+0

页面插件响应库是的,我加入其工作...如果我使用复选框然后它不工作 – helloworld

回答

0

我想你错过了什么,如果你想使用的数据表的扩展,那么你应该添加扩展库,否则将无法正常工作,

所以,你可以看到在这个环节的工作代码jsfiddle.net/1eLg1Lgy/

的JavaScript

$(document).ready(function() { 
    $('#example').DataTable({ 
     responsive: true, 
     columnDefs: [ { 
      orderable: false, 
      className: 'select-checkbox', 
      targets: 0 
     } ], 
     select: { 
      style: 'os', 
      selector: 'tr' 
     }, 
     order: [[ 1, 'asc' ]] 
    }); 
}); 

HTML

<table id="example" class="display" width="100%" cellspacing="0"> 
<thead> 
<tr> 
    <th></th> 
    <th>Name</th> 
    <th>Position</th> 
    <th>Office</th> 
    <th>Age</th> 
    <th>Salary</th> 
</tr> 
</thead> 
<tfoot> 
<tr> 
    <th></th> 
    <th>Name</th> 
    <th>Position</th> 
    <th>Office</th> 
    <th>Age</th> 
    <th>Salary</th> 
</tr> 
</tfoot> 
<tbody> 
<tr> 
    <td></td> 
    <td>Tiger Nixon</td> 
    <td>System Architect</td> 
    <td>Edinburgh</td> 
    <td>61</td> 
    <td>$320,800</td> 
</tr> 
</tbody> 

和推广链接在这里cdn.datatables.net/#Extensions

+0

感谢您的回复... @ferhat您的代码正在工作。我想要多个复选框选择。 – helloworld

+0

嗨,当你选择使用'ctrl',然后可以选择多个.. –

+0

在手机中没有'ctrl'按钮。我们在那里做什么? – helloworld

相关问题