cakePHP and Pagination

cakePHP and Pagination

martin@sommer.netmartin@sommer.net Posts: 15Questions: 0Answers: 0
edited March 2010 in General
Has anyone used DataTables with cakePHP, successfully implemented Pagination through Ajax, and can provide example code?

I am successfully populating the table from cakePHP, but am not getting the footer line "Showing X to Y of Z entries", am not getting paging, and am not sure how to pass the values iTotalRecords iTotalDispalyRecords.

Any examples?

Thanks,
Martin

Replies

  • pktmpktm Posts: 27Questions: 0Answers: 0
    I don't have an example, but I think you might g et what you need by looking into the sources of other languages. There are some examples here: http://datatables.net/forums/comments.php?DiscussionID=937&page=1

    hth, pktm
  • martin@sommer.netmartin@sommer.net Posts: 15Questions: 0Answers: 0
    Thanks pktm. I am looking for someone who has truly integrated DataTAbles with cakePHP, and used server-side processing. I have the DataTAble object now calling the function via Ajax, and am struggling in getting the data posted back into the table.

    A working cakePHP example, would be great.

    Martin
  • martin@sommer.netmartin@sommer.net Posts: 15Questions: 0Answers: 0
    I now have the data posting to the table, but am getting conflicts with the cakePHP debug function:

    http://datatables.net/forums/comments.php?DiscussionID=1718

    Any ideas?

    Thanks,
    Martin
  • martin@sommer.netmartin@sommer.net Posts: 15Questions: 0Answers: 0
    Done. Lessons learned:

    1) For the sAjaxSource parameter, use a combination of JavaScript and cakePHP:
    'sAjaxSource': src="<?= $this->base;?>/controller/action/<?=$dataId;?>"

    2) Dynamically turn off debug on the ajax function, so DataTables can read the returned json data:
    Configure::write('debug', 0);

    3) Use the "DataTables server-side processing example" as a base, and modify it for cake PHP:
    Ref: http://datatables.net/examples/data_sources/server_side.html

    Martin
  • guignol95guignol95 Posts: 1Questions: 0Answers: 0
    Hi martin
    could you give an example of a "modified code" adapted from "DataTables server-side processing example" .

    It's been 2 days that I'm killing myself trying to find a way to make Cake and datatable work together.

    Thanks, guignol
  • kelly.blue90kelly.blue90 Posts: 2Questions: 0Answers: 0
    owo what a great post!!! it helps me a lot to learn CakePHP.
    Also i find http://www.php-example.com/2010/08/20-steps-to-make-cakephp-blog-project.html useful to make CakePHP blog porject step by step code example.

    Kelly Blue
    University of Technology, Sydney, Australia
This discussion has been closed.