Support the ongoing development of Laravel.io →
Database
Last updated 2 years ago.
0

Hi!

Sorry that dosent help. Same error

Added -get() after ->rawColumns(['action']) ->make(true) ->get(); to, but then i get this error:

DataTables warning: table id=juge_table - Ajax error. For more information about this error, please see http://datatables.net/tn/7

???

Last updated 5 years ago.
0

Hi All!

Found the solution to this, hope that this can help others... `

public function index(Request $request) { if(request()->ajax()) { if($request->grad) { if($request->region) { $data = Judge::latest() ->join('grader', 'grader.ID', '=', 'judges.grad_id_ref') ->select('judges.id', 'judges.navn', 'judges.epost', 'judges.mobil','grader.grad_navn','judges.adresse','judges.postnr') ->where('judges.grad_id_ref', $request->grad) ->where( 'judges.region_id_ref', $request->region);

            }

            else
            {
                $data = Judge::latest()
                    ->join('grader', 'grader.ID', '=', 'judges.grad_id_ref')
                    ->select('judges.id', 'judges.navn', 'judges.epost', 'judges.mobil','grader.grad_navn','judges.adresse','judges.postnr')
                    ->where('judges.grad_id_ref', $request->grad);

            }

        }
        else
        {
            if($request->region)
            {
                $data = Judge::latest()
                    ->join('grader', 'grader.ID', '=', 'judges.grad_id_ref')
                    ->select('judges.id', 'judges.navn', 'judges.epost', 'judges.mobil','grader.grad_navn','judges.adresse','judges.postnr')
                    ->where( 'judges.region_id_ref', $request->region);

            }
            else
            {
                $data = Judge::latest()
                    ->join('grader', 'grader.ID', '=', 'judges.grad_id_ref')
                    ->select('judges.id', 'judges.navn', 'judges.epost', 'judges.mobil','grader.grad_navn','judges.adresse','judges.postnr');


            }

        }

            $recordsfound = datatables()->of($data)


            ->addColumn('action', function($data){


                //$button='<button onclick="window.location.href = \'/projects/'.$data->id.'/edit\';" type="button" name="edit" id="test"

                $button='<a href="javascript:;" data-toggle="modal" onclick="showData('.$data->id.')" 
                            data-target="#ShowModal" ShowModal" style="margin-top: 1px;margin-bottom: 1px;" class="btn btn-xs btn-secondary btn-sm contr"><i class="fa fa-eye"></i> Show</a>';
                $button .= '&nbsp';
                $button .='<button title='.$data->navn.' onclick="window.location.href = \'/judges/'.$data->id.'/edit\';" type="button" name="edit" id="test" 
                         style="margin-top: 1px;margin-bottom: 1px;" class="edit btn btn-primary btn-sm contr"><i class="fa fa-pencil"></i> Edit</button> ';
                $button .= '&nbsp';
                $button .='<a href="javascript:;" data-toggle="modal" onclick="deleteData('.$data->id.')" 
                            data-target="#DeleteModal" DeleteModal" style="margin-top: 1px;margin-bottom: 1px;" class="btn btn-xs btn-danger btn-sm contr"><i class="fa fa-trash"></i> Delete</a>';

                return $button;
            })
            ->rawColumns(['action'])
            ->make(true);

            return $recordsfound;
    }

    $grad = DB::table('grader')
        ->select("*")
        ->get();

    $regions = DB::table('regions')
        ->select("*")
        ->get();

    return view('judges.index', compact('grad'),compact('regions'));
}

`

Last updated 5 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.