All Projects → nacasha → CIgniter-Datatables

nacasha / CIgniter-Datatables

Licence: MIT license
CodeIgniter library for Datatables server-side processing / AJAX, easy to use :3

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to CIgniter-Datatables

Slice-Library
Slice-Library is a CodeIgniter library that simulates Laravel's Blade templating system!
Stars: ✭ 60 (+53.85%)
Mutual labels:  codeigniter, codeigniter-library
Datatables
PHP Library to handle server-side processing for Datatables, in a fast and simple way.
Stars: ✭ 185 (+374.36%)
Mutual labels:  datatables, codeigniter
Codeigniter-blockchain
A library to use the Blockchain Wallet API: https://blockchain.info/api/blockchain_wallet_api
Stars: ✭ 19 (-51.28%)
Mutual labels:  codeigniter, codeigniter-library
codeigniter-react-boilerplate
A CodeIgniter boilerplate with React.
Stars: ✭ 35 (-10.26%)
Mutual labels:  codeigniter
DataTablesBundle
Symfony bundle for DataTables plugin.
Stars: ✭ 13 (-66.67%)
Mutual labels:  datatables
codeigniter-tettei-apps
『CodeIgniter徹底入門』のサンプルアプリケーション(CodeIgniter v3.1版)
Stars: ✭ 26 (-33.33%)
Mutual labels:  codeigniter
datatables-bulma
DataTables styling for the Bulma CSS framework
Stars: ✭ 80 (+105.13%)
Mutual labels:  datatables
logi-filter-builder
advanced SQL filter builder. Demo:
Stars: ✭ 23 (-41.03%)
Mutual labels:  datatables
jQuery-datatable-server-side-net-core
A simple Visual Studio solution using jQuery DataTable with Server-Side processing using .NET 5
Stars: ✭ 71 (+82.05%)
Mutual labels:  datatables
GoInstaller
GoInstaller is installer for CodeIgniter with user interface (UI).
Stars: ✭ 31 (-20.51%)
Mutual labels:  codeigniter
django-rest-framework-datatables-editor
Seamless integration between Django REST framework, Datatables and Datatables Editor.
Stars: ✭ 25 (-35.9%)
Mutual labels:  datatables
vue-datatables
No description or website provided.
Stars: ✭ 22 (-43.59%)
Mutual labels:  datatables
vue-data-table
Smart table using vue.js - sorting columns, filter by string, child rows, custom columns, custom row data
Stars: ✭ 15 (-61.54%)
Mutual labels:  datatables
codeigniter-image-magician
🎨 An ImageMagick library for CodeIgniter.
Stars: ✭ 13 (-66.67%)
Mutual labels:  codeigniter
socialigniter
This is core install of social igniter application. Please follow the Readme below
Stars: ✭ 78 (+100%)
Mutual labels:  codeigniter
DataTables.AspnetCore.Mvc
HtmlHelper wrapper for jquery DataTables
Stars: ✭ 22 (-43.59%)
Mutual labels:  datatables
ExpressPHP-V1
✨ ExpressPHP V1是一个极简的 web 开发MVC框架,和ThinkPHP5一样现代化,比CodeIgniter还要轻量级,真正突破框架限制,让你感受到自由,同时兼顾高性能、低学习成本。
Stars: ✭ 13 (-66.67%)
Mutual labels:  codeigniter
codeigniter-alert
An easy flashdata alert for codeigniter
Stars: ✭ 20 (-48.72%)
Mutual labels:  codeigniter
wildfire
Query Builder wrapper for the Codeigniter framework.
Stars: ✭ 15 (-61.54%)
Mutual labels:  codeigniter-library
jquery.dataTables.TreeTable
Integrate jquery.treeTable into jquery.dataTables
Stars: ✭ 28 (-28.21%)
Mutual labels:  datatables

CIgniter-Datatables

CodeIgniter library for Datatables server-side processing / AJAX, easy to use :3

Important changes

Commit : 870b1caadbf9a2756b513c1e58fe5f153086b399

Change basic API to create Datatables

  • Old : $this->datatables->new();
  • New : $this->datatables->init();

Change API to init created datatables config

  • Old : $this->datatables->init();
  • New : $this->datatables->create();

Features

  1. Easy to use.
  2. Generates Datatable and JSON for server side processing in just one controller.
  3. Multiple Datatables in one page.
  4. Use CodeIgniter Query Builder Class to produce query (support all functions). Read Documentation
  5. Support columns rendering/formatting.
  6. Able to define searchable table columns.
  7. Configurable datatables options. Read Documentation

Wiki

  1. Basic Usage

Installing

  • jQuery

     <script type="text/javascript" language="javascript" src="https://github.com//code.jquery.com/jquery-1.11.1.min.js"></script>
    
  • DataTables

     <script type="text/javascript" language="javascript" src="https://github.com//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
    
  • CIgniter Datatables Library

    Download and place to your codeigniter libraries folder

Basic Example

Controllers

$this->load->library('Datatables');

$dt_authors = $this->datatables->init();

$dt_authors->select('*')->from('authors');

$dt_authors
    ->style(array(
	'class' => 'table table-striped table-bordered',
    ))
    ->column('First Name', 'first_name')
    ->column('Last Name', 'last_name')
    ->column('Email', 'email');

$this->datatables->create('dt_authors', $dt_authors); 

Views

$this->datatables->generate('dt_authors');

// Add this line after you load jquery from code.jquery.com
$this->datatables->jquery('dt_authors');

Usage

Use CodeIgniter Query Builder Class/Active Record to build SQL query. Read Query Builder Documentation

Create new variable to create initialize Datatables.

$dt_authors = $this->datatables->init();

Select columns and table. NOTE : Don't use ->get() or other method for executing the query, let the library do for you.

$dt_authors->select('first_name, last_name, email')->from('authors');

Use column() to add column to datatables.

$dt_authors
    ->column('First Name', 'first_name')
    ->column('Last Name', 'last_name')
    ->column('Email', 'email');

Create datatables instance using created configurations ($dt_authors) and provide unique name ('dt_authors')

$this->datatables->create('dt_authors', $dt_authors);

Generate table in views

$this->datatables->generate('dt_authors);
$this->datatables->jquery('dt_authors);

Column Rendering/Formatting

// $dt_authors is an example 
$dt_authors
    ->column('Name', 'name', function($data, $row){
    	return $row['first_name'] .' '. $row['last_name'];
    })
    ->column('Age', 'age', function($data, $row){
		return $data . ' years old';
    })
    ->column('Email', 'salary');

$t->create();

Custom searchable column

// $dt_authors is an example 
$dt_authors
    ->searchable('first_name, age'); 	// table columns
    // -> ... other chain methods

Datatable Options

DataTables and its extensions are extremely configurable libraries and almost every aspect of the enhancements they make to HTML tables can be customised.

You can use set_options add the options.

Note : Second parameter will not produce single quote, wrap option value with double quotes to produce single quotes or use escaping.

// $dt_authors is an example 
$dt_authors
    ->set_options('searching', 'false')			// searching : false
    ->set_options('pagingType', '\'simple\'')		// pagingType : 'simple'
  //->set_options('pagingType', "'simple'")
    ->set_options('lengthMenu', '[ 10, 25, 50, 75, 100 ]')	 // lengthMenu : [ 10, 25, 50, 75, 100 ]

You can use array too ...

->set_options(array(
    array('searching', 'false')
    array('pagingType', "'simple'")
    array('lengthMenu', '[ 10, 25, 50, 75, 100 ]')
));

Use set_options('ajax.data', '...') to override ajax data options

Show paginatin in top and bottom of Datatables

This is workaround incase you want to show pagination in both top and bottom of Datatables. I will create new API with the other changes when it ready.

Go to DatatablesBuilder.php and search for '$output' at line 176 and add this lines (#7)

    \"pagingType\": \"full_numbers\",
    \"sDom\": '<\"top\"lfprtip><\"bottom\"><\"clear\">',

Styling Tables

You can use style to add table tag attributes to styling your table.

// $dt_authors is an example 
$dt_authors
    ->style(array(
        'class' => 'table table-bordered table-striped',
    ))

Changelog

Version 1.5

  • Add new API to override ajax data
  • Support multiple datatables in one page
  • Fix unable to search on field contains null

Version 1.1

  • Fix searching when use alias for columns
  • Remove query_builder, use direct select() to build query

Version 1.0

  • Initial Release (Development)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].