I am trying to implement datatable in my form. I've a form and below that I've to show all the data present in the database.
I can not write the Route method for DataTable, the tutorial I was following teaches to display DataTable only, but here I have a form and below that display the DataTable. Please see the attached file.
// OrderedBookController controller class
use App\OrderedBook;
use Datatables;
public function index()
{
return view('pages.booksin');
}
function fetchData()
{
$ordered_books = OrderedBook::select('BookID', 'BilledNum','BilledDate', 'Qunatity', 'Price', 'Remarks');
return Datatables::of($ordered_books)->make(true); //return an instance of the class or interface you request
}
//OrderedBook model class
class OrderedBook extends Model
{
//
}
I do not know how to write route method to show the data. My web.php class
Route::resource('/order','OrderedBookController');
My view page is inside resources\views\pages\booksin.blade.php
view page sample code
<table id="showBooksIn" class="table table-bordered">
<thead>
<tr>
<th>BOOK ID</th>
<th>BILLED DATE</th>
<th>BILLED NUMBER</th>
<th>QUANTITY</th>
<th>PRICE</th>
<th>REMARKS</th>
</tr>
</thead>
</table>
<script type="text/javascript">
$(document).ready(function(){
$('#showBooksIn').DataTable({
"processing":true,
"serverside":true,
"columns":[
{"data": "BookID"},
{"data": "BilledNum"},
{"data": "BilledDate"},
{"data": "Qunatity"},
{"data": "Price"},
{"data": "Remarks"},
]
});
});
</script>
via Chebli Mohamed

Aucun commentaire:
Enregistrer un commentaire