How 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
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>
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?