Ap3twe
163
5
Laravel

DataTables Sorting & Searching not working

Posted 1 month ago by Ap3twe

I am using data tables in Laravel. The values are inserted with dynamic blade syntax. When I click ordering, it does not sort. Searching returns no match even though I provide the correct values. How do I solve this? NB: Looking in the chrome console, I see the table body changes state.

       //Table cases javascritpt
              $(document).ready( function () {
              $('#table_id').DataTable();

               } );
               $.extend( $.fn.dataTable.defaults, {

                 ordering: true,
                 searching:true,
                 select: true,
                 "order": [[ 0, 'desc' ], [ 1, 'desc' ], [2, 'desc'], [3, 'desc']]
              } );
 <table class="table table-striped table-bordered" id="table_id">
            <thead>
                    <tr>
                            <th>Case Number</th>
                            <th>Case Form</th>
                            <th>Patient Name</th>
                            <th>Date Created</th>
                            <th>Status</th>
                    </tr>
            </thead>
            @foreach ($project as $project)
            <tbody>
              
             <tr>
                
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->case_number}}</a></td>
                
                 @if ($project->services0)
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services0}}</a></td> 
                 @elseif ($project->services1)
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services1}}</a></td> 
                 @elseif ($project->services2)
                 {{-- <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services2 . '  '  . $project->mockup0}}</a></td>  --}}
                 <td> <a href="/smiledesign/{{$project->id}}/userproject">{{$project->services2 . '  '  . $project->mockup0 . ' ' . $project->mockup1}}</a></td> 

                 @endif

             </tr>

         </tbody>
         @endforeach

     </table>

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.