0

enter image description hereHow i can add extra parameter in the zend paging.I have to provide filter functionality in the listing user. so i want to send search keywords with page numbers.

Paging code

$page = $this->_getParam('page', 1);
        $paginator = Zend_Paginator::factory($data);
        $paginator->setItemCountPerPage(2);//PAGING_RESULT_PER_PAGE
        $paginator->setCurrentPageNumber($page);
        $paginator->setPageRange(PAGING_PAGES_RANGE_PER_PAGE);
        $this->view->users = $paginator;

I want to add search data onchange event to the paging . This paging is working using ajax now what i want to it should be changed as per the filter data. I am not able to perform this....can you please provlde me any suggestion please

Pramod Kumar Sharma
  • 7,851
  • 5
  • 28
  • 53

2 Answers2

1

I'm not quite sure what you mean with "extra parameter in the zend paging" ... are you trying to pass a GET-Parameter to an controller which has an paginator? What is inside $data? How does your search parameter and your route look like? You might try the following inside your bootstrap.php (if passing a get var is what you're struggling with):

protected function _initConstants()
{
    [...]

    defined('QSA_SEARCH') || define('QSA_SEARCH', 'q');

    [...]
}

And inside your controller you can access it via:

    [...]

    $search = $this->getRequest()->getParam(QSA_SEARCH);

    [...]

Passing a search string via get request:

http://domain.com/<controller>/<pagenum>?q=<searchstring>

e.g.:

http://domain.com/users/2?q=foo

EDIT: Or are you having problems passing the search string towards Zend_Paginator::factory?

simplyray
  • 1,200
  • 1
  • 16
  • 25
  • I have a input field over the user list now what i want to do is if a user search user with letter 'abc' then these letter automatecally get added in the paging. – Pramod Kumar Sharma Jan 03 '13 at 12:15
  • could you please provide the content of $data? You just have to add the content of $serach (see answer above) to $data before passing it to Zend_Paginator::factory. So if its a db request: $data->where('table.username LIKE ?', '%'.$serach.'%') – simplyray Jan 03 '13 at 12:18
  • I want to add parameter in the paging on change ......By the way thanks for reply .. – Pramod Kumar Sharma Jan 03 '13 at 12:26
  • Oh okay. How are you building the pagination? Are you using paginationControl()? Take a look at: http://stackoverflow.com/questions/5747673/passing-parameters-to-zend-paginationcontrol-partial – simplyray Jan 03 '13 at 12:28
1

You can change the code from the javascript.

<script>
$(document).ready(function(){
    $('.paginationControl a').click(function(){
        if($('#keyword').val() != '')
        {
            var href = $(this).attr('href')+'/keyword/'+$('#keyword').val();
            $(this).attr('href', href);
        }
    });
});
</script>

<input type="text" name="keyword" value="" id="keyword"/>


<div class="paginationControl">
  <a href="/page/2">2</a> 
  <a href="/page/3">3</a>
  <a href="/page/4">4</a>
  <a href="/page/5">5</a>
</div>
Nandakumar V
  • 4,317
  • 4
  • 27
  • 47