DataTable is a cakephp plugin for JQuery DataTables.
- CakePHP >= 2.2
- PHP >= 5.4
Documentation is available on wiki page
Update 02/05/2015
- v2.0.0 released which is not backwards compatible with v1.0.0
- The old master was tagged as v1.0.0
JQuery DataTable plugin server-side processing component for CakePHP
DataTable is a cakephp plugin for JQuery DataTables.
Documentation is available on wiki page
Update 02/05/2015
I would do it under my name but you might want to have rights to it :)
I get this error after follow the intructions on the readme file.
ReferenceError: dataTableSettings is not defined
var settings = dataTableSettings[model];
Missing some step?
I think I've followed all the steps needed to get this plugin working but I receive the following exception: DateTableComponent: Model not specified for request.
I've verified I am on the right version of CakePHP (2.2.3). I've cloned the plugin in the plugins directory, enabled in bootstrap, added the component to the controller, added the helper, created the necessary view file etc...
I can see within DataTableComponent that this exception is raised if !isset($this->_params['model']). Why is this not being set and what do I need to fix?
I'm trying to paginate an associated model inside of a view called view. The issue is: instead I get te JSON data, I'm getting the HTML of the view where I'm trying to render the Child data. Please help me telling me how it has to be done. Thanks in advance.
From my controller I'm calling the paginate method in the Parent controller as follows:
public funtion view(){
$this->DataTable->settings['columns'] = array(
'Child.PROVEEDOR' => 'Supplier',
'Child.DESTINATARIO' => 'Consignee',
'Child.NUMFACTURA' => 'Invoice number'
);
$this->DataTable->paginate = array('Parent', 'Child');
}
and in my view I render the table:
echo $this->DataTable->render('Child');
I also have the app/View/Parent/datatable/view.ctp file as this:
foreach($dtResults as $result) {
$this->dtResponse['aaData'][] = array(
$result['Child']['PROVEEDOR'],
$result['Child']['DESTINATARIO'],
$result['Child']['NUMFACTURA'],
);
}
Hi,
I have the default example working using my Users MVC, the pagination and sorting are working well, but when I make a search this not return the correct records.
There are some key code lines in my implementation.
bootstrap.php
CakePlugin::load('DataTable');
//-----------------------------------------------------------------------------------------
Layout.ctp
echo $this->Html->script('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js');
echo $this->Html->css('//cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css');
echo $this->Html->script('//cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js');
echo $this->fetch('dataTableSettings');
echo $this->fetch('script')
//-----------------------------------------------------------------------------------------
UsersController.php
public $components = array('Paginator', 'Session',
'DataTable.DataTable' => array(
'triggerAction' => array('index'), // use if your action is not 'index'
'columns' => array(
'id' => true, // bSearchable and bSortable will be false
'username' => 'Usuario', // bSearchable and bSortable will be true, with a custom label Nombre
'name' => array(
'bSearchable' => 'customSearch',// will use model callback to add search conditions
),
'email' => 'email',
'Acciones' => null, // tells DataTable that this column is not tied to a field
),
),
);
public $helpers = array(
'DataTable.DataTable',
);
public function index() {
$this->User->recursive = 0;
$this->DataTable->paginate = array('User');
}
//-----------------------------------------------------------------------------------------
index.ctp
echo $this->DataTable->render();
//-----------------------------------------------------------------------------------------
datatable/index.ctp
//-----------------------------------------------------------------------------------------
Model User.php
public function customSearch($field, $searchTerm, $columnSearchTerm, $conditions) {
if ($searchTerm) {
$conditions[] = array("$field LIKE" => '%' . $searchTerm); // only do left search
}
if ($columnSearchTerm) {
$conditions[] = array($field => $columnSearchTerm); // only do exact match
}
return $conditions;
}
I'm using CakePHP 2.5.3 & DT 1.10.2.
Thanks.
Hi,
I have an issue and i dont know how to solve it ...
I installed the plugin and it's working great, my table and data are displayed well, but it looks like all requests in my controller MachinesController are redirected to your plugin.
In my view index i have the table displayed and the action buttons View/Edit/Delete.
When i press Delete, i have this error :
Notice (8): Undefined index: model [APP\Plugin\DataTable\Controller\Component\DataTableComponent.php, line 118]
Notice (8): Undefined index: language [CORE\Cake\I18n\L10n.php, line 379]
Notice (8): Undefined index: locale [CORE\Cake\I18n\L10n.php, line 381]
Notice (8): Undefined index: localeFallback [CORE\Cake\I18n\L10n.php, line 382]
Notice (8): Undefined index: locale [CORE\Cake\I18n\L10n.php, line 385]
Notice (8): Undefined index: charset [CORE\Cake\I18n\L10n.php, line 386]
Notice (8): Undefined index: direction [CORE\Cake\I18n\L10n.php, line 387]
I also have this error in my view "Add" (datatable is not supposed to be used here). I have an ajax request on a button of this page and the previous error appears here.
When I remove the public $components = array( ... ) from the MachinesController, this error does not appear.
Do you have an idea how to solve my problem ? I dont want datatable to be loaded out of index view, it seems the problem is around here ...
I would appreciate some testing on this branch: https://github.com/tigrang/cakephp-datatable/tree/component
It's working on my computer, but I'm sure I broke something.
@shama what do you think, besides typos =P
conditions in action method not executing.
public function index()
{
$this->paginate['Avatar'] = array(
'conditions' => array('Avatar.id' => '3'),
);
}
Results are also fetching when I comment code in index action.
Is it mandatory to pass a model paramer in ajax request? ex: /avatars?model=Avatar
when i remove model parameter the data is not loading
Hi @tigrang ,
Thanks a lot for this awesome plugin.
I have an issue. How to create a condition by using this plugins?
Let say, I have many posts, and want the table to list only posts in current year. Normally, I can set conditions in find options (or in paginate).
$this->set('posts', $this->paginate('Post', array(
'YEAR(Post.created)'=>date('Y')
)));
But this code simply didn't work. For now, I just create if condition in View/Posts/datatable/index.ctp, inside the foreach. It work, but the table was messed up.
How do I make the same result with code above by using this plugin?
I'm getting that error when trying the example, even thought I loaded the helper in my controller:
public $helpers = array( 'DataTable.DataTable');
I use DataTable->render(); ?> in my index.ctp view file,
and:
Hi!
This Plugin is not able to be integrated with composer because it lacks the json file.
I'm trying to get the extra view processing to work. I disabled autoRender and created a /app/View/[Model]/datatable/[config_name].ctp file.
This file is not processed, all I get is an empty response. What am I doing wrong?
hi
thansk for plugin ...
but i have this js error:
DataTables warning (table id = 'DataTables_Table_0'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
Hi Tigrang,
How to change Datatable use POST method?
I hope to receive your feedback soon.
Thanks so much.
Regards,
MrHung91
I have this situation where I need to use column/value from a deep association model.
Sample Setup like this -
Model Andrews
id
name
belinda_id
belongsto Belinda
Model Belindas
id
name
belinda_child_id
belongsto BelindaChild
Model BelindaChilds
id
name
foreach ($dtResults as $result) {
$this->dtResponse['aaData'][] = array(
$result['BelindaChild']['name']
)
}
public $components = array(
'DataTable.DataTable' => array(
'columns' => array(
'BelindaChild.name',
)
)
);
public $helpers = array(
'DataTable.DataTable'
)
public function index() {
$this->DataTable->setting['Andrew'] = array(
'contain' => array(
'Belinda' => array(
'fields' => array(
'id',
'BelindaChild.id'
),
),
'BelindaChild' => array(
'fields' => array(
'id',
'name'
),
),
),
'fields' => array(
'id',
'name',
'Belinda.id'
),
),
}
With above codes, an error message would be like this - SQLSTATE[42S22]: Column not found: 1054 Unknown column BelindaChild.name in field list.
Is there another way to do this to use deep association models or someone has solutions for this?
When you set a pagination condition like this one in the controller
$this->paginate['Post'] = array(
'conditions' => array('OR' => array(...)),
);
If you use the dataTable search you lost your condition, I think the problem is the file Controller / Component / DataTableComponent.php in the function _search() at line 289 from
if (!empty($conditions)) {
$this->query['conditions']['OR'] = $conditions;
}
I have 4 records with limit 3.
But when I click on link page 2, It's only show prev 1 next.
is there a way to specify some callback and not get parsed as string to get something like this to the output:
$('#example').dataTable( {
"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
/* Modify the footer row to match what we want */
var nCells = nRow.getElementsByTagName('th');
nCells[1].innerHTML = parseInt(iPageMarket * 100)/100 +
'% ('+ parseInt(iTotalMarket * 100)/100 +'% total)';
}
} );
if specified as "fnFooterCallback" => "function()..." it get's wrapped in text and never get excuted..
Awesome Plugin. Many thanks!
I'm trying to figure out how to modify the Initialization code. For instance if I wanted full pagers, I would initialize with:
$(document).ready(function() {
$('#example').dataTable( {
"sPaginationType": "full_numbers"
} );
} );
What is the correct way to do this using your plugin?
Hi,
When I try to use quick search eg. I start to type the string to input field there is only "Processing..." info, and nothing happens. FireBug js console returns "NetworkError: 500 when trying to search". Any idea what could be the reason or how can I debug it? Beside quick search everything works fine, paginastion, sort. etc.
Regards
Kamil
I have two data sets (datatables) in the same view, they both fetch data from the same model. Normally I could just have the same settings in the related action and do the filtering on aoColumns on the front side. However, one data set is filtered based on data from another model, while the other isn't.
Any ideas??
I was having trouble with the pagination changing pages, so I modified the DataTableComponent _paginate() method to include this line at the bottom:
$settings['page'] = 1 + ($this->_params['iDisplayStart'] / $limit);
I haven't looking into the documentation enough but I don't think that the offset parameter works.
Note: I am using Cake lib v2.1.3.
Hi, I'm trying to get this great plugin work in my app but I'm facing an issue, when I click the pagination buttons, the response brings me the same data so i can't change the page. In the inspector I can see that the request is performing on every click.
Could you help me to get it work? Thanks in advance for you help!!!
This is my implementation:
StatesController.php
<?php
App::uses('AppController','Controller');
class StatesController extends AppController {
public $components = array(
'DataTable.DataTable' => array(
'columns' => array(
'code' => 'Code',
'name' => 'Name',
'Country.name' => 'Country',
),
),
);
public $helpers = array(
'DataTable.DataTable',
);
public function index() {
$this->DataTable->paginate = array('State', 'Country');
}
}
index.ctp
<div class="widget widget-simple widget-table">
<?php
$this->DataTable->settings['scriptBlock'] = 'datatable';
echo $this->DataTable->render('State');
?>
</div>
States\datatable\index.ctp
<?php
foreach($dtResults as $result) {
$this->dtResponse['aaData'][] = array(
$result['State']['code'],
$result['State']['name'],
$result['Country']['name'],
);
}
an this is the value for dataTableSettings var that is being generated by the helper
var dataTableSettings =
{"State": {
"sAjaxSource":"\/tms\/states?model=State",
"bServerSide":true,
},
"Country":{
"sAjaxSource":"\/tms\/states?model=Country",
"bServerSide":true
}
};
I am getting error
Uncaught ReferenceError: dataTableSettings is not defined
Wht should i do?
Hi there,
I've followed all the steps in your Documentation and also have read through several forum posts on the implementation with CakePHP and still can't retrieve any results. I hope you can help me on hand because I've tried all the different solutions on Google (for CakePHP integration with Server Side Processing), however most of them don't work well with me (especially the actions table). Many advanced thanks if you can lend me a hand.
This are the steps I've done: Using the latest Master copy package (below)
These are what I've done now: according to your latest documentation.
I want the data from Customers table to be presented in table form (on the Index) page with the action (edit, view, and delete buttons on the table) while looping through all records
CustomerController
public $components = array(
'DataTable.DataTable' => array(
//'triggerAction' => array('index'), // use if your action is not 'index'
'columns' => array(
'id' => 'id', // bSearchable and bSortable will be false
'firstname' => 'First Name', // bSearchable and bSortable will be true, with a custom labelName
// by default, the label with be a Inflector::humanize() version of the key
'lastname' => 'Last Name',
'email' => array(
'bSearchable' => 'customSearch',// will use model callback to add search conditions
),
'mobile_number' => 'Mobile Number',
'address' => 'Address',
'additional_notes' => 'Alt. Contact',
'Actions' => null, // tells DataTable that this column is not tied to a field
),
),
);
$helpers = array(
'DataTable.DataTable',
);
public function index() {
$this->DataTable->paginate = array('Customer');
}
This is based on your "Example - View File" concept:
Next, I have added a new 'index.ctp' file under app/View/Customers/datatable
fetch('dataTableSettings');?> fetch('script');?> dtResponse['aaData'][] = array( $result['Customer']['id'], $result['Customer']['firstname'], $result['Customer']['lastname'], $result['Customer']['email'], $result['Customer']['mobile_number'], $result['Customer']['address'], $result['Customer']['additional_notes'], 'actions', ); } ?>
Added bSearchable callback accordingly on 'Customer' Model page
public function customSearch($field, $searchTerm, $columnSearchTerm, &$conditions) {
if ($searchTerm) {
$conditions[] = array("$field LIKE" => '%' . $searchTerm); // only do left search
}
if ($columnSearchTerm) {
$conditions[] = array($field => $columnSearchTerm); // only do exact match
}
}
Customers/index.ctp
Also fetched 2 scripts that I've read in earlier threads
Also at this point: I've removed all CakePHP for each loop and TH, TR from the original code written by CakePHP to loop through the records and retrieve them (And it works fine: nothing wrong with retrieving from database)
To be honest,I am stuck here. I have tried to write countless of Javascript functions (from previous threads) and results (no results shown: only table headers that is called from the 'datatable' index.ctp page that are currently displayed).
Please guide me as I've been trying this out for a few days.
Thank you in advance and I hope for your soonest reply or anyone who has successfully implemented this and could help me a hand. Thank you.
Rae
Current result:
I am using Datatable 1.10.3 and CakePHP Version 2.5.4
Not sure whats going on. I looked in the datatables documentation to make sure there wasn't something I had disabled or enabled like regex vs smart filtering. From what I can tell everything is as it should. However what I did notice was after each character entered in the search box a GET method is made. When I look at the call I notice that is not breaking up the words by the whitespace as smart filter should work, here s a screenshot http://cl.ly/image/3L3I1x0f1S2c. As you can see the first sSearch has both words rather then splitting them up. Any help would be gratefully appreciated.
I have an application, which has a view that needs to contain two datasets - lets say I have View Customer action in my controller. I want to show all contacts that exist with this customer, but I also wish to show all open support requests for this customer. Both of these models are related customer, but not to each other.
What I tried:
In my controller, I put the following code
$dTcolumns = array(
'Contact' => array(
'id' => true,
'first_name' => true,
'email' => true,
'telephone0' => true,
'Action' => null
),
'Call' => array(
'id' => true,
'priority' => true,
'user' => true,
'closed' => true,
'date' => true,
'Action' => null
)
);
$this->DataTable->settings['triggerAction'] = 'view_client';
$this->DataTable->settings['columns'] = $dTcolumns;
$this->layout = "datatables";
$this->DataTable->paginate = array('Contact','Call');
$this->layout = "datatables";
$this->set('client', $currentClient);
$this->render('test_view_client');
And in my View, I have :
echo $this->DataTable->render('Call',array('class' => 'dataTable table table-striped table-bordered'), $js_call);
echo $this->DataTable->render('Contact',array('class' => 'dataTable table table-striped table-bordered'),
$js_contact);
$js_call and $js_contact are both arrays containing the settings for each datatable.
Before I carry on with this path, I am just wondering if what I want is possible.
Cheers,
Gareth
Hi,
I'm trying to use the plugin on top of a cakePHP 2.2.2 application. I have followed the README, but I have a problem with the Ajax calls, they are not going to the View/stuff/datatable/action.ctp. Instead, they are directed to View/stuff/action.ctp, which is my regular cake view file.
Then, datatable in the browser complains that the returning data is not JSON (of course it's not). In Firebug, I see an Ajax query going to stuff/action?long-params...
Maybe a reason, but not sure about its real impact : I upgraded the app from cakePHP 2.0, and I'm using JSON views elsewhere.
Help appreciated,
TIA, Charles
So I can maintain it and stuff. PLEASSSSEEEE
Can you please explain in simple terms with an example, how can I implement this plugin.
I tried to do exactly you have mentioned in the readme doc but not able to render the result. As I am a newbie I am not familiar in this i may be wrong some where. Please help me to implement this.
Tigrang thanks a lot for such a great plugin. I am building "delete" links that are based on (if-conditions) data from another un-related model!
Is there anyway to pass a variable/array from the controller to the Users/datatable/index.ctp view?
One I try to pass such array I find it passed to the users/index.ctp instead (the normal way). But I really need this array to build the actions links for the $this->dtResponse['aaData']
One aside question please: how do you add css classes to the in the view? I'm not using the helper. (manually)
Thanks
Is it normal that the initialisation script is echoing in all the views of the controller where I'm using the component and the helper?
It's happening even if I don't render a table in a view.
Im using the bug-fixes branch
my code:
public $components = array(
'DataTable.DataTable' => array(
'columns' => array(
'Task.id' => array(
'bSearchable' => 'plainSearch',
'bSortable' => true
),
'Task.inicio' => array(
'bSearchable' => false,
'bSortable' => true
),
'Task.fim' => array(
'bSearchable' => false,
'bSortable' => true
),
'Task.titulo' => array(
'bSearchable' => 'plainSearch',
'bSortable' => true
)
)
)
);
public $helpers = array(
'Js',
'DataTable.DataTable'
);
public function index() {
if ($this->request->is('ajax')) {
$this->DataTable->paginate();
}
}
I need put condition in my query, how can i do?
After successfully implementing my index.ctp with this plugin, now I am trying to do the same exact thing with another view (view.ctp) that also includes a datatables set. But its not working! The ajax request doesn't go through at all!
The response type is always "html". Here is how my view.ctp datatables settings:
in my view action inside the controller (Courses):
$this->DataTable->settings = array(
'Course' => array( 'recursive' => 0 ) ,
'triggerAction' => array('view') // tried to use array('index', 'view') with no luck
);
$this->DataTable->paginate = array('Course');
Any help please?
Hi,
I'm using your plugin for showing a list products. I'm using helper to render table. For now, I want to add class attribute to tags in table. So I can bind click event when user click on tags. Can you tell me how I can do this?
One more question, how can I add my callback functions after a row/table is drawed?
Thanks so much.
Hi @tigrang .. thanks for the plugin.. how can i use the belongs to relationship in the controller..?
I have two models:
*Collects:
public $belongsTo = array(
'Laborer' => array(
'className' => 'Laborer',
'foreignKey' => 'laborer_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
*Laborer:
public $hasMany = array(
'Collect' => array(
'className' => 'Collect',
'foreignKey' => 'laborer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
and in my Collects Controller inside index function:
$this->DataTable->paginate = array('Collect');
And i want to display the laborer name.. not just the laborer_id... can i do that?
Thanks in advance.
Hi
It seems your plugin does not detect actions with admin routing (e.g. it does not find admin-index.ctp).
An other problem Ive is that it does not append the model name in "sAjaxSource".
Could you help?
Thanks a lot,
Frank
public $paginate = array();
public $components = array(
'DataTable.DataTable' => array(
'Block' => array(
'columns' => array(
'title' => 'Título' ,
'Page.title' => 'Página Mãe' ,
'Ações' => NULL ,
// tells DataTable that this column is not tied to a field
) ,
) ,
'triggerAction' => '*'
)
);
public function solutionscms_index( $id = NULL )
{
if ( !is_null( $id ) && $this->request->is( 'ajax' ) ) {
$this->DataTable->paginate = array( 'Block' );
$this->DataTable->settings['Block']['scope'] = array( 'Block.page_id' => $id );
$this->DataTable->process();
}
else if ( is_null( $id ) && !$this->request->is( 'ajax' ) ) {
$this->redirect(
array( 'controller' => 'pages' ,
'action' => 'index'
)
);
}
}
Cannot use conditions, even with ['scope']. It's a simple "WHERE page_id = " . $id
The error that I encounter is the Component renders the table without conditions.
When running manually the process() and debugging I can see the return of the database is correct.
SQL query:
SELECT COUNT(*) AS `count` FROM `nexus`.`dmep_blocks` AS `Block` LEFT JOIN `nexus`.`dmep_pages` AS `Page` ON (`Block`.`page_id` = `Page`.`id`) WHERE `Block`.`page_id` IS NULL
Tigrang , you have made a great job !
Thanks for this plugin!
$conditions parameter should be &$conditions in custom search function to be taken in account.
'%' . $searchTerm); // only do left search } if ($columnSearchTerm) { $conditions[] = array($field => $columnSearchTerm); // only do exact match } } } AnsleyHello,
i have no solution to send $this->params to a condition ?
public function beforeFilter() {
parent::beforeFilter();
$this->DataTable->settings[$this->modelClass]['conditions'] = array(
$this->modelClass.'.client_id' => $this->Auth->user('client_id'),
$this->modelClass.'.status' => ??
);
Hi Tigrang,
The search (Global filter) is not working when I pump utf8 inputs.
Example: ầ, đ, ơ...
My app return 500 Internal Server Error
Here s a screenshot: http://cl.ly/image/2o1C2V1x0b0f
I hope to receive your feedback soon.
Thanks so much.
Regards,
MrHung91
I'm trying to use individual column filtering with your plugin but it's not working
http://datatables.net/release-datatables/examples/api/multi_filter_select.html
Maybe it's not implemented yet. Is it?
I have looked through other similar issues but couldn't solve my problem.
I need to sort or order by mymodel.id DESC before processing to json format.
This mymodel.id is not displayed in view
I open js debug tool and have a looked at my json data. it is not in order
pardon me...
how tu use it in controller and in the view..?.
i'm new in cakephp :)
Hello,
i have a problem if i want to traduce the column names with __() in my controller settings
public $components = [
'DataTable.DataTable' => [
'Badge' => [
'columns' => [
'id' => 'Réf',
'num_serigraphe' => 'Numéro de sérigraphie',
'num_serie' => 'Numéro de sérigraphie',
'status' => 'Status',
'created' => 'Créé le',
'modified' => 'Modifié le',
'' => null,
],
'autoData' => false,
//'autoRender' => false
],
],
];
Hi, I have declared in my AppController.php some $components and $helpers like this:
public $components = array( 'DebugKit.Toolbar','Session','Acl','Auth');
public $helpers = array('Html' => array('className' => 'BoostCake.BoostCakeHtml'),'Form' => array('className' => 'BoostCake.BoostCakeForm'),...);
Having this configuration in AppController my question is: How to declare 'DataTable.DataTable' component and helper in individual Controllers like Users.php if it's not possible to redeclare classes? Which is the best configuration to use your plugin?
I'm fan of JS datatables but newbie in CakePHP.
Thanks.
Hi tigrang. First of all thanks for this awesome Plugin.
In the past my dataTableSettings was empty. Recently I updated to the latest master and now I got
var dataTableSettings = {"Registration":{"bServerSide":true,"sAjaxSource":"\/nexus\/solutionscms\/registrations"}};
that throws me an error:
DateTableComponent: Model not specified for request.
you see, the sAjaxSource doesn't come with ?model=Registration
The SolutionsCMS part is the admin prefix. So the view is solutions_index.ctp
<?php
foreach($dtResults as $result) {
debug($result);
$this->dtResponse['aaData'][] = array(
$result['Registration']['razao_social'],
$result['Registration']['cnpj'],
$result['Registration']['email'],
'actions',
);
}
public $components = array(
'DataTable.DataTable' => array(
'Registration' => array(
'columns' => array(
'razao_social' => 'Razão Social' ,
'cnpj' => 'CNPJ' ,
'email' => 'E-mail' ,
'Ações' => NULL ,
// tells DataTable that this column is not tied to a field
)
) ,
'triggerAction' => '*'
) ,
);
public
function solutionscms_index()
{
$this->layout = 'SolutionsCMS.index';
// $this->Registration->recursive = 0;
// $this->set( 'registrations' , $this->paginate() );
$this->DataTable->paginate = array( 'Registration' );
}
Hi,
I want to show Datatable with sorted data eg. 'Model.example DESC'.
Should I use Cake's 'ORDER' in DataTable->settings (that doesn't work) or try 'aaSorting' from jquery Datatabels? "aaSorting":{"4":"desc"} also doesn't work.
Regards,
Kamil
I'm using your plugin for displaying a list products in my site.
Currently, I'm getting an issue about paging, it's saying 'Showing 1 to 100 of NaN entries (filtered from NaN total entries)'.
I'm using helper:
In ProductsController, I added:
public $components = array(
'DataTable.DataTable' => array(
'columns' => array(
'Product.title',
'Product.code',
'Product.qty',
'Product.id',
'Actions' => null
)
),
);
public $helpers = array(
'DataTable.DataTable'
);
And index() function:
public function index() {
$this->Product->recursive = 0;
$this->DataTable->paginate = array('Product');
}
In layout file, I added the code echo $this->fetch('dataTableSettings'); to above of fetch('script'); ?>
In View/Products/datatable/index.ctp, I added code below:
dtResponse['aaData'][] = array( $result['Product']['title'], $result['Product']['code'], $result['Product']['sku'], $result['Product']['asin'], $result['Product']['qty'], $result['Product']['id'], 'actions', ); } In View/Products/index.ctp, I added code below: Datatable->render();?>Then I've tried to view list products, I see it's showing good except paging's saying 'Showing 1 to 100 of NaN entries (filtered from NaN total entries)'.
I've used firebug to see responses after running at the first time, and I see:
{"iTotalRecords":3278,"iTotalDisplayRecords":3278,"sEcho":1,"aaData":[["NONE","DILLIGAF Wings ","0110","PAT-0528",null,"16","4826","actions"],["NONE","Proud Son ","0663","",null,"9","5878","actions"],....
I'm using CakePHP version 2.3.2
Can you tell me what's wrong? If you need any another info, please let me know. Thanks for your help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.