Skip to main content
Version: 2.0.1

Introduction

CI4-DataTables is a datatables library that will speed up you to create serverside datatable API using the CodeIgniter v4 framework.

This is an example code for using this library:

PHP:

<?php namespace App\Controllers;

use Irsyadulibad\DataTables\DataTables;

class Home extends BaseController
{
public function json()
{
return DataTables::use('users')
->where(['role' => 'admin'])
->hideColumns(['password'])
->rawColumns(['bio'])
->make(true);
}
}

JavaScript:

$('#table').DataTable({
processing: true,
serverSide: true,
ajax:{
url: 'http://localhost:8080/json'
},
columns: [
{data: 'username', name: 'username'},
{data: 'email', name: 'email'},
{data: 'fullname', name: 'fullname'}
{data: 'bio', name: 'bio'}
]
});