0

my website contain basic CRUD operation with ajax build in, my question is, how to implement datatable? by the way, I already deploy yajra datatable

js file

$(function () {

    $('#example').DataTable({

});});

function manageRow(data) {
var rows = '';
$.each( data, function( key, value ) {
    rows = rows + '<tr>';
    rows = rows + '<td>'+value.title+'</td>';
    rows = rows + '<td>'+value.description+'</td>';
    rows = rows + '<td data-id="'+value.id+'">';
    rows = rows + '<button data-toggle="modal" data-target="#edit-item" class="btn btn-primary edit-item">Edit</button> ';
    rows = rows + '<button class="btn btn-danger remove-item">Delete</button>';
    rows = rows + '</td>';
    rows = rows + '</tr>';
});
$("tbody").html(rows);}

view

<table id="example" class="display" cellspacing="1" width="100%">
<thead>
   <tr>
     <th>Name</th>
     <th>Position</th>
     <th>Office</th>
 </tr>
</thead>

<tbody>

</tbody></table>

2 Answers 2

1
  1. Create a model in Laravel
  2. Create a controller for that model, register the routes

I think StackOverflow is not the place to right the application for you. If you have special questions on that, I can help you.

Sign up to request clarification or add additional context in comments.

2 Comments

i tried laracast but no one willing to help, actually i do have model and controller build in for that, i followed a tutorial from other site, but i just wanted to implement datatables
create a migration script for the model, edit the migration script and add your columns and run a migration on the database. e.g you can get all objects from the DB Model::all() for more details: Migrations and get the models
1

The documentation is really straightforward, if you follow the example it should work. https://datatables.yajrabox.com/eloquent/basic

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.