Ajax pagination with filters in cakephp

2019-04-16 16:18发布

Can anybody give a best example of ajax pagination in cakephp 2.x.

This should include data filtering also.

I have read cakephp manual but could not understand much.

标签: cakephp-2.0
1条回答
We Are One
2楼-- · 2019-04-16 16:44

After a long search and work, i have developed a solution which is as follows:

Client Side:

  • Fist of all create a form with all filtering options.
  • Submit the form using ajax.
  • Use Post method to submit the form.
  • Submit the form using serialize method.

Server Side:

  • All filter form data will be available in $this->request->data.
  • Set PaginatorHelper options as mentioned below:

    $this->paginator->options(array(

    'url' => $this->passedArgs,
    
    'update' => 'element_id_to_be_updated',
    'evalScripts' => true,
    'data'=>http_build_query($this->request->data),
    'method'=>'POST',
    

    ) );

  • 'url' => $this->passedArgs To post back all named arguments, when pagination links are clicked.

  • 'data'=>http_build_query($this->request->data) To post back all post data, when pagination links are clicked.

查看更多
登录 后发表回答