Skip to content

Basic Usage

izalfat23 edited this page Feb 21, 2017 · 3 revisions

Controllers

class Welcome extends CI_Controller{

	public function index()
	{
		$this->load->library('datatables');

		$t = new Datatables;
		$t->select('fullname, age, salary')->from('employees');

		$t->datatable('employees_table')
			->column('Name', 'fullname')
			->column('Age', 'age')
			->column('Salary', 'salary');

		$t->init();

		$this->load->view('welcome_message');
	}

}

Views

<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css">

<?php
	$this->datatables->generate();

	$this->datatables->jquery();
?>
Clone this wiki locally