jeudi 14 septembre 2017

Column search not working in datatables if use two table

I've Two table join table 1 and table 2, I used datatables working properly but search column not working its say

"Exception Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pengelolaan_surat.nama_status' in 'where clause' (SQL: select count(*) as aggregate from (select '1' as row_count from pengelolaan_surat inner join status_surat on pengelolaan_surat.id_status = status_surat.id_status where (@rownum + 1 like %j% or LOWER(pengelolaan_surat.no_surat) LIKE %j% or LOWER(pengelolaan_surat.judul_surat) LIKE %j% or LOWER(pengelolaan_surat.tgl_masuk) LIKE %j% or LOWER(pengelolaan_surat.nama_status) LIKE %j% or LOWER(pengelolaan_surat.tgl_dispo) LIKE %j% or LOWER(pengelolaan_surat.pelaksana) LIKE %j%)) count_row_table)"

and here's my Datatables

public function data(Request $req)
    {
        DB::statement(DB::raw('set @rownum=0'));
        $pengelolaan = PengelolaanSurat::select([
            DB::raw('@rownum  := @rownum  + 1 AS rownum'),
            'pengelolaan_surat.id_surat', 
            'pengelolaan_surat.no_surat',
            'pengelolaan_surat.judul_surat',
            'pengelolaan_surat.tgl_masuk',
            'pengelolaan_surat.id_status',
            'pengelolaan_surat.tgl_dispo',
            'pengelolaan_surat.pelaksana',
            'status_surat.nama_status'
        ])->join('status_surat', 'pengelolaan_surat.id_status', '=', 'status_surat.id_status');

        $pengelolaantables = Datatables::of($pengelolaan)
            ->addColumn('action', function ($pengelolaans) {
                return '
                <a href="'. route("pengelolaan-surat.view", $pengelolaans->id_surat) .'"><i class="fa fa-eye"></i></a>
                <a href="'. route("pengelolaan-surat.edit", $pengelolaans->id_surat) .'"><i class="fa fa-edit"></i></a> 
                <a href="'. route("pengelolaan-surat.delete", $pengelolaans->id_surat) .'"><i class="fa fa-trash"></i></a>';
            })
            ->editColumn('id_surat', '');

        if ($keyword = $req->get('search')['value']) {
            $pengelolaantables->filterColumn('rownum', 'whereRaw', '@rownum  + 1 like ?', ["%{$keyword}%"]);
        }

        return $pengelolaantables->make(true);
    }

How do I fix this ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire