Implementing datatables in codeigniter

Implementing datatables in codeigniter

ninja_yanninja_yan Posts: 9Questions: 0Answers: 0
edited October 2012 in General
Hello everyone! I have a working datatables in plain php a few months ago. Now that I'm studying CodeIgniter, I want to implement datatables server side. The problem is how do I do it? I have this following code.

views:
[code]

$(document).ready(function() {
$('#users_table').dataTable({
"sScrollX": "100%",
"sScrollXInner": "100%",
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"bDeferRender": true,
"sAjaxSource": '<?php echo base_url(); ?>/users/get_active_users'
});
});




Username
Full Name
Office
Position
Email
Privilege
Date Registered




[/code]

model:
[code]
public function active() {
$query = $this
->db
->select('username, last_name, office, email, privilege, datetime_registered')
->where('status', 'Active')
->where('username !=', $this->session->userdata('username'))
->get('users');
return $query->result(); //return result to array
}
[/code]

controller:
[code]
public function get_active_users() {
$results = $this->user_management->active(NULL, TRUE);
echo json_encode($results);
}
[/code]

Screenshot: http://imageshack.us/a/img163/6937/93541166.png

Replies

  • ninja_yanninja_yan Posts: 9Questions: 0Answers: 0
    The
    [code]
    $this->load->model('user_management');
    [/code]

    is at the constructor and working
  • ninja_yanninja_yan Posts: 9Questions: 0Answers: 0
    Nice forum. Thank you for the feedback!
  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    I got an e-mail from another DataTables user at the end of last week with a link to a project he has been working on to allow integration of CodeIgnitor and DataTables: https://github.com/blake-nouribekian/codeigniter-datatables .

    There is also https://github.com/IgnitedDatatables/Ignited-Datatables/ .

    Also the documentation for server-side processing with DataTables is here:
    http://datatables.net/usage/server-side

    We are not able to provide support for those libraries here, nor is this the place to ask PHP / CodeIgniter specific questions as you'll be able to get better help else where.

    Allan
This discussion has been closed.