tigrang / cakephp-datatable

JQuery DataTable plugin server-side processing component for CakePHP
47 stars 29 forks source link

Paging's not working perfectly. #30

Closed ducnguyenvn closed 11 years ago

ducnguyenvn commented 11 years ago

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 <?php echo $this->fetch('script'); ?>

In View/Products/datatable/index.ctp, I added code below: <?php foreach($dtResults as $result) { $this->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: <?php echo $this->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.

NEOSolutions commented 11 years ago

Are you using the bug fix branch? On Jun 6, 2013 12:42 PM, "ducnguyenvn" notifications@github.com wrote:

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 <?php echo $this->fetch('script'); ?>

In View/Products/datatable/index.ctp, I added code below: <?php foreach($dtResults as $result) { $this->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: <?php echo $this->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"],....

Can you tell me what's wrong? If you need any another info, please let me know. Thanks for your help.

— Reply to this email directly or view it on GitHubhttps://github.com/tigrang/cakephp-datatable/issues/30 .

ducnguyenvn commented 11 years ago

No, I'm using master branch.

ducnguyenvn commented 11 years ago

Hi NEO, you mean I should use the bug fix branch, right? Sorry, I'm newbie here.

ducnguyenvn commented 11 years ago

I just used the bug-fixes branch but still getting the same issue. If you find solution for this, please let me know.

Thanks so much.

tigrang commented 11 years ago

Give me three weeks, I'm almost done with school, I'll take a look.

ducnguyenvn commented 11 years ago

I added my code above, can you have a look there and suggest me what I should do to fix this?

Sorry, but I don't think I can wait three weeks, I wish you can help me sooner.

Thanks.

tigrang commented 11 years ago

Which version of the jquery datatable plugin are you using? Try grabbing the latest version (1.9.4) The response json looks right, I don't see why it shouldn't be working.

ducnguyenvn commented 11 years ago

Hi Tigrang,

I've fixed it by replacing jquery datatable to 1.9.4. Thanks so much.

I will comment here if I have an another issues.

Thanks again.

tigrang commented 11 years ago

Cool, glad it worked.

ducnguyenvn commented 11 years ago

Hi again,

I want to show full numbers instead of links next/previous and want to show 100 records instead of 20 records as now, can you tell me how I can do that?

Thanks.

tigrang commented 11 years ago

Sure, change your render call to $this->DataTable->render(null, array(), array('sPaginationType' => 'full_numbers', 'iDisplayLength' => 100))

This will set the default limit to 100, but you will still have the option for 10, 20, 50, 100 from the dropdown. If you want to change those, look into the aLengthMenu option. Although, please limit issues to this cake plugin only. Thank you.

ducnguyenvn commented 11 years ago

Thanks Tigrang,

I'm having a good table now. Thanks for great plugin. Can you please help me another questions?

I wish to integrate jquery.editinplace (https://code.google.com/p/jquery-in-place-editor/) into your plugin. It will help me edit values in table inplace. By the way, I was success with this thing by rendering table that don't use your helper. For now, I'm using helper. Can you suggest me how I can do that?

Also, how to add a new th into my table and its td won't show any data from database?

Thanks much.