Topic: Datatable MB5
I use Codeigniter PHP. How can i use the search option with datatable search (datatable MD5)? In the documentation and sample video they use javascipt. I know it fully works with the original datatable repository, but i want it to work with the MD 5 version. Below an example with a foreach loop.
<div class="card-body">
<h4 class="header-title"><a class="btn btn-primary btn-rounded width-md waves-effect waves-light mb-4" href="<?= route_to('department_new') ?>">Nieuw</a></h4>
<?php if (isset($departments) && count($departments)) : ?>
<table id="department-datatable" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Id</th>
<th>Naam</th>
<th>Omschrijving</th>
<th>Gemaakt op</th>
<th>Acties</th>
</tr>
</thead>
<tbody>
<?php foreach ($departments as $item): ?>
<tr>
<td><?= $item->id ?></td>
<td><?= $item->name ?></td>
<td><?= $item->description ?></td>
<td><?= $item->created_at ?></td>
<td>
<a class="btn btn-purple waves-effect waves-light" href="<?= route_to('department_show', $item->id) ?>">Bekijken</a>
<a class="btn btn-info waves-effect waves-light" href="<?= route_to('department_index') ?>">Locaties</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else : ?>
<h4 class="text-center">Helaas er zijn geen afdelingen gevonden</h4>
<?php endif ?>
</div> <!-- end card body-->
Closed
This topic is closed.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Closed
Specification of the issue
- User: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: 1.0.0
- Device: Laptop
- Browser: Firefox
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Magdalena Dembna staff premium commented 4 years ago
How do you initialize your datatable? I can't see neither
datatable
class nornew Datatable()
init? JavaScript code is necessary for the search option. You need to add an event listener for theinput
event (your custom input field) and call.search()
method on the Datatable's instance with its value.snelledre commented 4 years ago
Ok, Then i use the standard Datatable and not the MD5 version. Because the standard Datatable from internet has default search without the javascript version of MD5.
André