snelledre free asked 3 years ago

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">
                        <th>Gemaakt op</th>
                    <?php foreach ($departments as $item): ?>
                            <td><?= $item->id ?></td>
                            <td><?= $item->name ?></td>
                            <td><?= $item->description ?></td>
                            <td><?= $item->created_at ?></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>
                    <?php endforeach; ?>

            <?php else : ?>

                <h4 class="text-center">Helaas er zijn geen afdelingen gevonden</h4>

            <?php endif ?>

        </div> <!-- end card body-->

Magdalena Dembna staff commented 3 years ago

How do you initialize your datatable? I can't see neither datatable class nor new Datatable() init? JavaScript code is necessary for the search option. You need to add an event listener for the input event (your custom input field) and call .search() method on the Datatable's instance with its value.

snelledre free commented 3 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.



Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: 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