在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:nacasha/CIgniter-Datatables开源软件地址:https://github.com/nacasha/CIgniter-Datatables开源编程语言:PHP 100.0%开源软件介绍:CIgniter-DatatablesCodeIgniter library for Datatables server-side processing / AJAX, easy to use :3 Important changesCommit : 870b1caadbf9a2756b513c1e58fe5f153086b399 Change basic API to create Datatables
Change API to init created datatables config
Features
WikiInstalling
Basic ExampleControllers $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
UsageUse 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 $dt_authors->select('first_name, last_name, email')->from('authors'); Use $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')
Generate table in views
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 OptionsDataTables 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 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 Show paginatin in top and bottom of DatatablesThis 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)
Styling TablesYou can use
ChangelogVersion 1.5
Version 1.1
Version 1.0
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论