dataTable ajax URL not working in laravel 5.0 - laravel

In my application using dataTable. In that ajax URL we are using. But while running, error message showing url not found kind. But it is there in route file. Why it showing like that?
My dataTable code is,
var oTable = $('.table').DataTable({
"oLanguage": {
"sSearch": "Search all columns:"
},
searching: false,
"processing": true,
"serverSide": true,
"ajax": {
"url": "{{ URL::to('loadfeedback') }}",
"data": function (d) {
d.from_date = $('#from_date').val();
}
},
"columns": [
{"data": null},
{"data": "name"},
],
'columnDefs': [
{
"searchable": false,
"orderable": false,
"targets": 0
},
],
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
var index = iDisplayIndex + 1;
$('td:eq(0)', nRow).html(index);
return nRow;
},
'iDisplayLength': 25,
"sPaginationType": "full_numbers",
"dom": 'T<"clear">lfrtip',
"order": [[0, 'desc']]
});
In routes.php
Route::get('loadfeedback', 'HomeController#loadfeedback');
In Controller.php
public function loadfeedback() {
$input = Input::all();
return Admin::loadfeedback($input);
}
What's wrong on this? And also it's working fine in my local system. After hosting only this issue found. But only this url, others are working fine.
Please help me.

Related

DataTables Searching Option is not working

If i search "Hossain" datatable is not getting sorted. Though this data is available in datatable. How can i solve this problem?
var table = $('#list_table').DataTable( {
"processing": true,
"serverSide": true,
"destroy": true,
"searching": true,
"ordering": true,
"bInfo": true,
"paging": true,
"ajax": {
"url": "{{URL::to('/')}}/current_employeelist",
"type": "POST",
"headers":{'X-CSRF-TOKEN': '{{ csrf_token() }}'},
"data": {location: $("#location").val()}
},
"columns": [
{
"render": function (data, type, JsonResultRow, meta) {
return '<img src="{{asset('employee_image')}}/'+JsonResultRow.Images+'" style="height:30px; width:30px; border-radius: 30px;"/>';
}
},
{ "data": "Link",
"mRender": function (data, type, full) {
return '<a target="_blank" href="{{URL::to('/')}}/employeeinfo/'+full.id+'">'+full.employee_name+'</a>';
}
},
{ "data": "location_name" },
{ "data": "depertment_name" },
{ "data": "designation_name" },
{ "data": "contact_number" },
{ "data": "joining_date" },
#permission('EditEmployeeInfo')
{ "data": "Link", name: 'action', orderable: false, searchable: false},
#endpermission
],[enter image description here][1]
"order": [[0, 'asc']]
});
I want to get searching actual data from datatable.
Image is here

v-on:click not working with datatables

I am using yajra datatables:
var table = $("#dt_user_draw").DataTable({
destroy: true,
processing: true,
responsive: true,
serverSide: true,
ordering: false,
"ajax": {
"method": "GET",
"url": 'url'
},
"columns": [
{
"data": "user"
},
{
"data": "email"
},
{
"data": "registered_at",
},
{
"render": function (data, wea, row) {
return '<i v-on:click="showDrawUser" class="nav-icon far fa-eye fa-fw " aria-hidden="true" title="Ver Draw"></i>';
}
},
]
});
In the last row, add v-on:click but this is not working. I do not how to do to vue render after datatables load

How to load huge data in html table using laravel and data table

I have a bookings data. At-present it has 10000 rows. How can list data using laravel and datatable with out taking too much loading time. At-present I had tried to list booking but initial loading took 20seconds. Currently fetching all data from database using ajax request. Please check my code and correct me.
I am referring "https://github.com/yajra/laravel-datatables" and "https://datatables.net/"
BookingController.php
public function index()
{
return view('backend.bookings'/*, ['bookingDetails' => $bookings]*/);
}
public function dataTables(Request $request)
{
$bookings = Booking::where('is_delete', 0)
->get();
// Functionality for laravel datatables
$bookingDetails = Datatables::collection($bookings)
->addColumn('action', function ($bookings) {
return '<i class="glyphicon glyphicon-trash"></i> Delete';
})
->make(true);
return $bookingDetails;
}
web.php
/* Listing bookings */
Route::get('/bookings', 'BookingController#index');
/* Show datatable page */
Route::post('/bookings/datatables', 'BookingController#dataTables')->name('bookings.datatables');
booking.js
/* Functionality for data table begin */
var table = $('#dataTable').DataTable({
/*"processing": true,
"serverSide": true,*/
/*"dom": '<"toolbar">frtip',*/
"order": [],
"ajax": {
"type": "POST",
"url": '/admin/bookings/datatables',
"contentType": 'application/json; charset=utf-8',
"data": { "_token": "" }
},
/*"ajax": '/bookings/datatables',*/
"dataType": "jsonp",
"columns": [
{"data": function(data){
return '<input type="checkbox" name="id[]" value="'+ data._id +'" />';
}, "orderable": false, "searchable": false, "name":"_id" },
{"data": function ( data ) {
if(!data.invoice_number){
return '<span class="label label-default">No data</span>'
}
else {
return '<a class="nounderline modalBooking" data-toggle="modal" data-target="#bookingModal_'+ data._id +'" data-modalID="'+ data._id +'">'+data.invoice_number+'</a>';
}
}, "name": "invoice_number"},
{"data": "usrEmail", "name": "usrEmail"},
{"data": "checkin_from", "name": "checkin_from"},
{"data": "reserve_to", "name": "reserve_to"},
{"data": "beds", "name": "beds"},
{"data": "dormitory", "name": "dormitory"},
{"data": "sleeps", "name": "sleeps"},
{"data": "status", "name": "status"},
{"data": "payment_status", "name": "payment_status"},
{"data": "payment_type", "name": "payment_type"},
{"data": "total_prepayment_amount", "name": "total_prepayment_amount"},
{"data": "txid", "name": "txid"},
{"data": "action", "name": "action", "orderable": false, "searchable": false}
],
"columnDefs": [{
"defaultContent": "-",
"targets": "_all"
}],
});
$('#dataTable tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search ' + title + '"/>' );
});
I had the same problem and now I've decided to move to a different approach which relies on APIs and saving database on the client.
Basically, the client downloads the database on connection and stores it in a JSON variable. When loading the page, you can just pass it a Vue component which will pull the database and render the table.
If you prefer to maintain the current system you can use pagination, but any kind of filtering of the data should be managed with another AJAX request instead of relying on the client.

DataTables: Ajax include space in search filter

I have this code but i can't do a search filter with space or comma,
I need do a smart search with ajax on datatables
Datatables ajax code:
$(document).ready(function () {
oDtable = $('#exc').dataTable({
"scrollX": true,
"scrollY": 300,
"oSearch": { "bSmart": false, "bRegex": true },
"processing": true,
"serverSide": true,
"ajax": "/ajax/getJSONResultsForDT?table=eventos&primaryKey=id",
"columns": [
{"data": 'nombre'},
{"data": 'descripcion'},
{"data": 'fecha_inicio'},
{"data": 'fecha_fin'},
{"data": "created_by"},
{"data": "updated_by"},
{"data": null}, //6 y 7
{"data": null}
],
"columnDefs": [
{
"targets": [6],
"orderable": false,
"render": function (data) {
$id = data.id;
return '<button class="btn btn-default" data-toggle="modal" data-target="#edit-modal">Edit</button>';
}
},
{
"targets": [7],
"orderable": false,
"render": function (data) {
return '<a class="btn btn-danger" data-fancybox-type="iframe">' + 'Delete' + '</a>';
}
}],
"bPaginate": true,
"sPaginationType": "full_numbers",
});
});
don't know what else to write
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

Laravel Chumper datatables.net

i'm newbie in laravel and want to use datatables.net. i want to using chumper datatables.net in my projects? after installing that. how to use or update this code for server side (sAjaxSource)?
oTable_categories =$('#showCategories').dataTable({
"bLengthChange": false,
"iDisplayLength": 6,
"bScrollCollapse": true,
"bJQueryUI": true,
"bAutoWidth": false,
"sAjaxSource": "server_processing.php",
"sPaginationType": "full_numbers",
"bProcessing": true,
"fnDrawCallback": function() {
clickRowHandler_categories();
},
"fnServerParams": function ( aoData ) {
aoData.push(
{"name": "id" , "value": "id" },
{"name": "title" , "value": "title" },
{"name": "join" , "value": "" },
{"name": "action" , "value": "categories" }
)}
});
function clickRowHandler_categories() {
$('#showCategories tbody tr').bind('click', function () {
var aData = oTable_categories.fnGetData( this );
if ( aData == null ) return false;
iId_categories = aData[0];
});
}
i must be define new route such as :
Route::controller(
'mediaManagment','mediaManagmentController',
array(
'getIndex' => 'mediaManagment.index',
'postUpdate' => 'mediaManagment.update',
)
);
i do not know how to use that.
thanks
Here, "sAjaxSource": "server_processing.php" should contain the url of your controller which is sending more/paginated data/records/models so use the mediaManagment because this URL will invoke the getIndex() method. So, use something like this:
"sAjaxSource": "mediaManagment" // http://example.com/mediaManagment
Do the processing in your getIndex() method.

Resources