Closed luisillo26 closed 11 years ago
You should paginate only State model, but I'm not certain about this.
You are using 'bug-fixes' branch?
The Model of Cake would automagically know about country, and set that variable for you.
Lucas Freitas Consultor em Informática +55 51 8483-8242 / +55 51 3338-4832 lucas@lucasfreitas.com.br www.lucasfreitas.com.br
2013/1/18 luisillo26 notifications@github.com
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
<?phpApp::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
States\datatable\index.ctp
<?phpforeach($dtResults as $result) { $this->dtResponse['aaData'][] = array( $result['State']['code'], $result['State']['name'], $result['Country']['name'], );}
an this is the value for dataTableSettings var tha is being generated by the helper
var dataTableSettings = {"State": { "sAjaxSource":"\/tms\/states?model=State", "bServerSide":true, },"Country":{ "sAjaxSource":"\/tms\/states?model=Country", "bServerSide":true }};
— Reply to this email directly or view it on GitHubhttps://github.com/tigrang/cakephp-datatable/issues/23.
I'm using the bug-fixes branch and already changed it to render the State model and it's the same.
A weird thing is that the string with the paging info is updating correctly, it shows me the _from # to # entries_ correctly
You are manually initializing the dataTable? You should inspect with Firebug or Chrome the request and see what's going on. Further information is helpful.
Thanks for help me out! this are the params sent wit the request for the initial page
** 1358794272370_
bRegex false
bRegex_0 false
bRegex_1 false
bRegex_2 false
bSearchable_0 true
bSearchable_1 true
bSearchable_2 true
bSortable_0 true
bSortable_1 true
bSortable_2 true
iColumns 3
iDisplayLength 10
iDisplayStart 0
iSortCol_0 0
iSortingCols 1
mDataProp_0 0
mDataProp_1 1
mDataProp_2 2
model State
sColumns
sEcho 1
sSearch
sSearch_0
sSearch_1
sSearch_2
sSortDir_0 asc
and this is the response
{"iTotalRecords":83,"iTotalDisplayRecords":83,"sEcho":1,"aaData":[["AGS","Aguascalientes","mexico"],["AK","Alaska","usa"],["AL","Alabama","usa"],["AR","Arkansas","usa"],["AZ","Arizona","usa"],["BCN","Baja California","mexico"],["BCS","Baja California Sur","mexico"],["CA","California","usa"],["CAM","Campeche","mexico"],["CHI","Chihuahua","mexico"]]}
so when I click on the link to get the second page, it sends the folowing params:
** 1358794573381_
bRegex false
bRegex_0 false
bRegex_1 false
bRegex_2 false
bSearchable_0 true
bSearchable_1 true
bSearchable_2 true
bSortable_0 true
bSortable_1 true
bSortable_2 true
iColumns 3
iDisplayLength 10
iDisplayStart 10
iSortCol_0 0
iSortingCols 1
mDataProp_0 0
mDataProp_1 1
mDataProp_2 2
model State
sColumns
sEcho 2
sSearch
sSearch_0
sSearch_1
sSearch_2
sSortDir_0 asc
and the response is equal to the previous one except for the parameter sEcho
{"iTotalRecords":83,"iTotalDisplayRecords":83,"sEcho":2,"aaData":[["AGS","Aguascalientes","mexico"],["AK","Alaska","usa"],["AL","Alabama","usa"],["AR","Arkansas","usa"],["AZ","Arizona","usa"],["BCN","Baja California","mexico"],["BCS","Baja California Sur","mexico"],["CA","California","usa"],["CAM","Campeche","mexico"],["CHI","Chihuahua","mexico"]]}
I don't know what I'm doing wrong because ordering and Displaylenght are working as they should.
Hey, did you ever resolve this? I'm using my plugin currently in a project and it is working just fine.
Which cake version are you using?
Please re-open if you have questions.
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
index.ctp
States\datatable\index.ctp
an this is the value for dataTableSettings var that is being generated by the helper