Monday, December 4, 2023
 Popular · Latest · Hot · Upcoming
111
rated 0 times [  114] [ 3]  / answers: 1 / hits: 6080  / 4 Years ago, thu, june 11, 2020, 12:00:00

so I am working with dataTables and I am having trouble on showing the checkboxes on my tables. So I have this code:



<table id=employeeList class=table table-sm table-bordered table-hover cellspacing=0 width=200%>
<thead class=blue lighten-2>
<tr>
<th>RTO</th>
<th>Name</th>
<th>Address</th>
<th>RTO Score</th>
<th>Production Machine</th>
<th>Transportation Availability</th>
<th>Department/Team</th>
<th>Return to Office Date</th>
<th>Willingness</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Sample</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td></td>
<td>Sample2</td>
<td>1</td>
<td>123</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
</tr>
</tbody>




And I have the script which enable the dataTable to have both vertical and horizontal scrolling and supposedly the checkboxes on the first-child of the table.



<script>
$(document).ready(function () {
$('#employeeList').dataTable({
scrollX: true,
scrollY: 350,
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'os',
selector: 'td:first-child'
}
});
$('.dataTables_length').addClass('bs-select');
});




Is there something I missed? Thank you very much for the help.


More From » html

 Answers
6

Datatable is case-sensitive, check your line $('#employeeList').dataTable({ and then check mine below:



$(document).ready(function() {
$('#employeeList').DataTable({
scrollX: true,
scrollY: 350,
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'os',
selector: 'td:first-child'
}
});
$('.dataTables_length').addClass('bs-select');
});


Also be sure to include these in your head tag:



<link rel=stylesheet type=text/css href=https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css>
<link rel=stylesheet type=text/css href=https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css>

<script type=text/javascript language=javascript src=https://code.jquery.com/jquery-3.5.1.js></script>
<script type=text/javascript language=javascript src=https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js></script>
<script type=text/javascript language=javascript src=https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js></script>

[#3507] Tuesday, June 9, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luzv

Total Points: 178
Total Questions: 105
Total Answers: 114

Location: Palau
Member since Tue, May 30, 2023
7 Months ago
luzv questions
Thu, Aug 26, 21, 00:00, 2 Years ago
Mon, Nov 23, 20, 00:00, 3 Years ago
Wed, Apr 29, 20, 00:00, 4 Years ago
Sun, Apr 26, 20, 00:00, 4 Years ago
;