Category : yajra-datatable

I am new to Laravel and ajax and I am trying to apply Custom filters on Table data. I have followed this tutorial https://www.youtube.com/watch?v=XmUH049dk9I but unfortunately it’s not working. I have used yajra data tables. Here is my controller code. <?php namespace AppHttpControllers; use IlluminateHttpRequest; use DB; class CustomSearchController extends Controller { function index(Request $request) ..

Read more

I have a mysql query that contains few conditioned columns such as FORMAT((vehi.mb – vehi.start_price),2) AS sp_minus_mb when I try to search it shows vehi.sp_minus_mb column not found. In the datatable I also try this and it’s not working columns:[ {data: ‘sp_minus_mb’, name: ‘vehicles.mb – vehicles.start_price’}, ] How can I add this kind of data ..

Read more

Datatables version: 1.10.19 Laravel: 7.3 880k record data Problem: Show first 10 results correct, little slow, but ok… Mostrando de 1 até 10 de 880.951 registros So, when i click on second page, show: Mostrando de 11 até 20 de 880.951 registros But not show records: Nenhum registro encontrado (No records found) admin_template.blade.php $.extend(true, $.fn.dataTable.defaults, ..

Read more

I have use Yajra datatables in my Laravel project, but there is a problem when sorting (also searching) datatables. column ‘created_at’ in order clause is ambiguous I know that this error is because other tables has ‘created_at’ column. but I don’t know how to fix it. Here is my controller: public function index() { $partners ..

Read more

I have invoices table, which uses yajra laravel datatable. I want to filter data using ‘created_at‘ column, which does exists in invoices table in the database but not in the table view. Here is my datatable image: and the code which takes start and end dates: $(function() { $(‘#invoices_daterange’).daterangepicker({ opens: ‘left’ }, function(start, end, label) ..

Read more

I’ve been studying this yajrabox tutorial https://www.tutsmake.com/laravel-8-ajax-crud-using-datatable-tutorial/ how the author add a new column for ‘company-action’, which it is a blade file. public function index() { if(request()->ajax()) { return datatables()->of(Company::select(‘*’)) ->addColumn(‘action’, ‘company-action’) ->rawColumns([‘action’]) ->addIndexColumn() ->make(true); } return view(‘companies’); } but this is a defective codes, as he just added a new column for string ‘company-action’. ..

Read more

I want to display sum of the expense of my service_numbers. Service numbers and Expense has a hasMany relationship. like this in ServiceNumber model: public function expense(){ return $this->hasMany(Expense::class); } Expense model has attribute expense which holds monthly expense of each service numbers. Like this in Expense migration: Schema::create(‘expenses’, function (Blueprint $table) { $table->id(); $table->foreignId("service_number_id")->references("id")->on("service_numbers")->onDelete("CASCADE")->onUpdate("CASCADE"); ..

Read more

I want to Put a single column in the child row of multiple parent columns in datatable/yajra datatable. till now I have done this much but don’t know how to put a single column below multiple columns. ‘columns’: [ { ‘data’: ”, ‘name’: ”, "defaultContent": ""}, // { ‘data’: ‘website_url_value’, ‘name’: ‘website_url_value’}, { data: null, ..

Read more

I want to show audit trail data in datatables. column old_values and new_values are array in database. i’m using yajra-datatable. Old_values/new_values value in db something like this {"updated_at":"2021-05-03 09:30:17.248","var_allowance_1":"500.00",**"var_allowance_2":"300.00"**} But in the view, column old/new_values, it only show the latest array. for example only show var_allowance_2 = 300.00 instead of all value (i.e) updated_at = ..

Read more

I have js code like this, the diffrent is only on index of column datatable and class from input data. $(‘.kouban_id’).keyup(function () { var term = $(this).val(); table.column( 3 ).search( term, true, false ).draw(); }); $(‘.edaban_id’).keyup(function () { var term = $(this).val(); table.column( 4 ).search( term, true, false ).draw(); }); So I just create dynamic ..

Read more

I have a table data and i using datatables yajra . its show normally , and i add Button download to download file . this file type is Pdf. how to download pdf file from public folder? this is my controller code: public function getAgreement() { $data = Agreement::with(‘years’, ‘agrements’, ‘agreekinds’) ->select(‘*’) ->latest()->get(); return Datatables::of($data) ..

Read more

I am getting parameter missing error, I make a route where I pass the id and use yajaraTbale ajax request to show data in yajaraTable, but I am getting parameter missing error because I don’t know to pass id in route when we use yajara for Data showing // Route Route::get(‘profileList-state/{id}’,’[email protected]’)->name(‘profile.listState’); Controller public function profilelistState(Request ..

Read more

I try to make filter datatable by dropdown in yajra laravel datatable but i got error like this, its error happen when i try to make filter datatable by dropdown https://drive.google.com/file/d/1niig3672QWwxQbt7JG9h0GQHVqMxnP37/view?usp=sharing This is my controller public function index(Request $request) { $title="Data Pelamar Kerja"; if (request()->ajax()){ $query = Applicant::with(‘formation’)->get(); // $query = Applicant::all(‘formation’)->where(‘status’,’active’)->get(); return DataTables::of($query) ->addColumn(‘action’, ..

Read more

I am trying to make a DataTables dropdown filter in Yajra Laravel DataTables but I get an error: This is my controller: public function index(Request $request) { $title="Data Pelamar Kerja"; if (request()->ajax()){ $query = Applicant::with(‘formation’)->get(); // $query = Applicant::all(‘formation’)->where(‘status’,’active’)->get(); return DataTables::of($query) ->addColumn(‘action’, function($item){ return ‘ <div class="btn-group"> <a href="#!" data-toggle="tooltip" data-id="’.$item->id.’" class="btn btn-sm btn-danger delete-data">Hapus</a> ..

Read more

I have a problem with an eloquent result using Datatables component. This is my code: $licences = Licence::with([‘purchase.company’, ‘catalog_package.catalog’, ‘catalog_package.package’, ‘createdContact’]); return Datatables::of($licences) ->addColumn(‘actions’, function (Licence $licence) { $ret = ‘<a href="’. url("/") .’/licences/edit/’. $licence->id .’" class="btn btn-info waves-effect waves-light" data-toggle="tooltip" data-placement="top" title="" data-original-title="’. ucfirst(trans("messages.edit")) .’"><i class="fa fa-list-ul"></i></a>’; return $ret; }) ->rawColumns([‘actions’, ‘end_date’]) ->make(); The ..

Read more

I am using Yajra Datatables to fetch the data inside my table. I need to display the data of the table accreditors wherein the nonofficial_category_id column for the said table should display the area_name equivalent of it from another database table non_officials_categories. Here is the Accreditors Model showing its relationship with NonOfficialsCategories Model: <?php namespace ..

Read more

I’m using Laravel and Laravel DataTable ^8.0 version. Adding Dataable skipTotalRecords() in DataTable eloquent builder not working. Count query still coming in results. Here is attaching my screenshots From clockwork debug bar SELECT count(*) as aggregate FROM (SELECT id, row_no, customer_id, income, posting_date, (SELECT posting_date FROM final_invoice WHERE job_id = job.id and final_invoice.deleted_at IS NULL ..

Read more

Is there a way to order a datatable by an added column? I couldn’t figure it out . Example: return datatables()->of(Restaurant::select(‘id’,’denumire’)->where(‘id_stare’,1)->with([‘orders’=> function($q) use($startDate, $endDate){ $q->where(‘created_at’, ‘>=’,$startDate->toDateTimeString())->where(‘created_at’, ‘<=’,$endDate->toDateTimeString()); }]) ) ->addIndexColumn() ->addColumn(‘suma’, function(Restaurant $restaurant) { $suma = $restaurant->orders->sum(function($item){ return $item->total; }); return intval($suma); }) ->make(true); In front i use the JavaScript DataTable framework , but the ..

Read more