CodeIgniter4-DataTables icon indicating copy to clipboard operation
CodeIgniter4-DataTables copied to clipboard

Do you have a complete example available?

Open Josh5A opened this issue 1 year ago • 2 comments

I can't get any of the examples as written to work. They all seem to be missing instructions. For example, simple initializing has a javascript section but what file does that code go into?

When I try this:

<?php

namespace App\Controllers;

use \Hermawan\DataTables\DataTable;

class Test extends BaseController
{
    public function index()
    {
        $db = $this->db;
        $builder = $db->table('mytable')->select('id, title');
        
        return DataTable::of($builder)->toJson();
        
    }
}

I get the following error:

{
    "error": "no datatable request detected"
}

Josh5A avatar Jun 09 '24 07:06 Josh5A

Try switching to $db = db_connect();

xgrind avatar Jul 16 '25 00:07 xgrind

It is because you request not using DataTable js, DataTable (js) sending some information in every request that used by this library

poetrasapoetra avatar Sep 13 '25 20:09 poetrasapoetra