jeudi 9 janvier 2020

How can I create a clickable link with Yajra data-tables server side

Controller where I am getting all the data.

return Datatables::of($usersData)->make(true); 

On the view:

<table id="AllData" class="table table-striped display" cellspacing="0" width="100%" >
            <thead>
            <tr>
                <th>Subject</th>
                <th>Business</th>
                <th>Device</th>
            </tr>
            </thead>
            </table> 

Then JavaScript

<script type="text/javascript">
        $(document).ready(function() {
             $('#AllData').DataTable({
                dom: 'Bfrtip',
                aLengthMenu: [[5, 10, 25], [5, 10, 25]],
                iDisplayLength: 10,
                processing: true,
                serverSide: true,
                responsive: true,
                autoWidth:false,
                "ajax": "",
                "columns":[
                    { "data": "subject"},
                    { "data": "businessName" },
                    { "data": "device_name" }
                ],
                buttons: ['csv', 'excel', 'pdf', 'colvis']
             });
        });
    </script> 

This works fine. I can view the data.

I however want to have the first td as a link as <td><a href="/review/show/{!! >reviewSlug !!}" target="_blank">{!! subject !!}</a></td>

How can I achieve this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire