Tagged: codeigniter server side get data with datatable

jQuery Datatable Server Side Processing with codeigniter 0

jQuery Datatable Server Side Processing with codeigniter

jQuery Datatable Server Side Processing with codeigniter

In this Post We Will Explain About is jQuery Datatable Server Side Processing with codeigniter With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Data table Server Side Processing with codeigniter Example

In this post we will show you Best way to implement Datatable demo (Server side) in codeigniter,Mysql and Ajax, hear for DataTables – Development – server-side processing using codeigniter with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Controllers – crud.php

 defined('BASEPATH') OR exit('No direct script access allowed');  
 class Crud extends CI_Controller {  
      //Codeigniter functions  
      function index(){  
           $data["title"] = "codeigniter c.r.u.d. with modals & ajax free download";  
           $this->load->view('crud_view', $data);  
      function get_student(){  
           $getStud_data = $this->ci_crud_model->make_datatables();  
           $data = array();  
           foreach($getStud_data as $data_row)  
                $stud_arr = array();  
                $stud_arr[] = '<img src="'.base_url().'upload/'.$data_row->image.'" class="img-thumbnail" width="100" height="30" />';  
                $stud_arr[] = $data_row->student_fname;  
                $stud_arr[] = $data_row->student_lname;  
                $stud_arr[] = '<button type="button" name="update" id="'.$data_row->id.'" class="btn btn-warning btn-xs">Update</button>';  
                $stud_arr[] = '<button type="button" name="delete" id="'.$data_row->id.'" class="btn btn-danger btn-xs">Delete</button>';  
                $data[] = $stud_arr;  
           $output = array(  
                "draw"                    =>     intval($_POST["draw"]),  
                "recordsTotal"          =>      $this->ci_crud_model->get_student_list(),  
                "recordsFiltered"     =>     $this->ci_crud_model->get_stud_filterData(),  
                "data"                    =>     $data  
           echo json_encode($output);  

Models – ci_crud_model.php

 class Crud_model extends CI_Model  
      var $table = "students";  
      var $select_column = array("id", "student_fname", "student_lname", "image");  
      var $order_column = array(null, "student_fname", "student_lname", null, null);  
      function student_query()  
                $this->db->like("student_fname", $_POST["search"]["value"]);  
                $this->db->or_like("student_lname", $_POST["search"]["value"]);  
                $this->db->order_by($this->order_column[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);  
                $this->db->order_by('id', 'DESC');  
      function make_datatables(){  
           if($_POST["length"] != -1)  
                $this->db->limit($_POST['length'], $_POST['start']);  
           $get_query = $this->db->get();  
           return $get_query->result();  
      function get_stud_filterData(){  
           $get_query = $this->db->get();  
           return $get_query->num_data_rows();  
      function get_student_list()  
           return $this->db->count_all_results();  

Include External Script

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<!-- Devloped by Pakainfo.com free download examples -->  
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>  
<!-- Devloped by Pakainfo.com free download examples -->
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>            
<!-- Devloped by Pakainfo.com free download examples -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />  

Views – crud_view.php

   <title><?php echo $title; ?> Pakainfo.com</title>   
 <!-- Devloped by Pakainfo.com free download examples -->
      <div class="container box">  
           <h3 align="center"><?php echo $title; ?></h3><br />  
           <div class="table-responsive">  
                <hr />  
                <table id="student_data" class="table">  
                               <th width="20%">Student Image</th>  
                               <th width="20%">Student First Name</th>  
                               <th width="20%">Student Last Name</th>  
                               <th width="15%">Student Edit</th>  
                               <th width="20%">Student Delete</th>  


      var dataTable = $('#student_data').DataTable({  
                url:"<?php echo base_url() . 'crud/get_student'; ?>",  
                     "targets":[0, 3, 4],  


	border:1px solid #4d4ds4;  

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example


I hope you have Got What is Server-side DataTables in Codeigniter using jQuery And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.