Welcome Guest, Not a member yet? Register   Sign In
Datatables library
#3

Hi,
It should be in the main directory. 
CI 3 already has the composer.json file as default.

when you run "composer install"  it will create a vendor file.



Code:
"require-dev": {
"mikey179/vfsStream": "1.1.*",
"phpunit/phpunit": "4.* || 5.*"
}


and because of this section exists it installs some test suits for you. (if you dont want to use these, you can remove them. and run "composer update" to update vendor folder.)


Still if you don't want to use composer, and only if you insist, these instructions are for you.

1- Download github repo. 
2- Copy src folder into your application/libraries folder,
3- rename it to Datatables from src
4- create a new file called Datatables.php in the application/libraries folder
5- copy the codes below and save it.

Datatables.php

PHP Code:
<?php
include_once "Datatables/Datatables.php";
include_once 
"Datatables/DB/DatabaseInterface.php";
include_once 
"Datatables/DB/CodeigniterAdapter.php";

use 
Ozdemir\Datatables\Datatables as DT;
use 
Ozdemir\Datatables\DB\CodeigniterAdapter;

class 
Datatables extends DT {
    function __construct()
    {
        parent::__construct(new CodeigniterAdapter);
    }



and in your controller usage will be simply like this : 

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

    public function 
index()
    {
        
$this->load->view('welcome_message');
    }

    public function 
ajax()
    {
        
$this->load->library('Datatables');
        
        
$dt $this->datatables->query("select name, surname, phone, address from users");
        
        echo 
$dt->generate();
    }

I hope it helps you :Smile (with this, I think you can run it with CI 2.0 too.)
Regards
Reply


Messages In This Thread
Datatables library - by numberone - 05-15-2016, 12:15 PM
RE: Datatables library - by Corsari - 06-19-2017, 11:21 PM
RE: Datatables library - by numberone - 06-20-2017, 11:50 AM
RE: Datatables library - by lowld - 11-14-2017, 02:16 PM
RE: Datatables library - by numberone - 12-28-2018, 12:55 PM
RE: Datatables library - by numberone - 10-03-2020, 01:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB