APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
493 stars 343 forks source link

Pagination issue #220

Closed sanraj closed 12 years ago

sanraj commented 12 years ago

Hi, when i change page from drop down (for eg. 20) & then i click on next page button my drop down is getting reset. I know this is bydefaut change but if i want to keep constant what i do?

Thanks

sterrien commented 12 years ago

you mean your result per page value ?

sanraj commented 12 years ago

yes yes

sterrien commented 12 years ago

Which browser do you use ?

sanraj commented 12 years ago

crome

sterrien commented 12 years ago

Do you have the same behavior when you order your grid and then click on next page button (order is getting reset) ?

Abhoryo commented 12 years ago

Can you paste your controller code for the grid?

sanraj commented 12 years ago

$source = new \APY\DataGridBundle\Grid\Source\Entity($sourceEntity);

$grid = $controller->get('grid');

$tableAlias = $source::TABLE_ALIAS; $source->manipulateQuery(function ($query) use ($tableAlias, <$someparameter>) { $query->andWhere($tableAlias . '.field in (:options)'); $query->setParameter('options', <$someparameter>); });

$grid->setSource($source);

$rowEditAction = new \APY\DataGridBundle\Grid\Action\RowAction('Edit', ''); $rowEditAction->setRouteParameters(array('id')); $grid->addRowAction($rowEditAction);

Abhoryo commented 12 years ago

And the rest ? Do you call $grid->isReadyForRedirect() ?

(There is a in() method on the query object)

sanraj commented 12 years ago

no

Abhoryo commented 12 years ago

Do you call $grid->getGridResponse() or $gridManager->getGridManagerResponse() ?

sanraj commented 12 years ago

no we hv'nt called

Abhoryo commented 12 years ago

If you don't call one of these methods, the grid is not computed and nothing work.

Follow the entire getting started toturial.

sanraj commented 12 years ago

actually our grid working fine. Only its issue is of changing page limit.

Abhoryo commented 12 years ago

If you call $grid->getGridResponse(), does it work ?

sanraj commented 12 years ago

we are using like this,

return $grid->getGridResponse('KRABundle::grid.html.twig');

not working, error occoured Fatal error: Call to undefined method Symfony\Component\HttpFoundation\Response::getHash() in /var/www/Symfony/vendor/bundles/APY/DataGridBundle/Twig/DataGridExtension.php on line 99

Abhoryo commented 12 years ago

It seems that you don't have the last version of the bundle.

sanraj commented 12 years ago

Hi,

We did download master copy

and modified our code as

$source = new \APY\DataGridBundle\Grid\Source\Entity($sourceEntity);

$grid = $this->get('grid');

$tableAlias = $source::TABLE_ALIAS; $source->manipulateQuery(function ($query) use ($tableAlias, <$someparameter>) { $query->andWhere($tableAlias . '.field in (:options)'); $query->setParameter('options', <$arrayparameter>); });

$grid->setSource($source);

$grid->setRouteParameter('menu', $this->getRequest()->get('menu')); $grid->setRouteParameter('submenu' , $this->getRequest()->get('submenu'));

$rowEditAction = new \APY\DataGridBundle\Grid\Action\RowAction('Edit', ''); $rowEditAction->setRouteParameters(array('id')); $grid->addRowAction($rowEditAction);

return $grid->getGridResponse('KRABundle::grid.html.twig');

when I comment $grid->setRouteParameter() calls, grid pagination works fine but when the calls are uncommented grid pagination does not work...

any specific note regarding the solution of the problem would be appreciated.

Abhoryo commented 12 years ago

With this call you change the url of the grid, so the no-persistence feature can't work (referer = current url). In your case you have to enable persistence. $grid->setPersistence(true);

utpalkadam commented 12 years ago

We added a $grid->setPersistence(true) call but no luck so far...

but one noticeable thing is in url we found 'menu=21&submenu=23&grid_9843d3f9c4588a51e30f08ff9affde79[_limit]=100' which I am guessing is wrong ...

Abhoryo commented 12 years ago

Try again with the last commit.

utpalkadam commented 12 years ago

appreciate your help... issue seems to be resolved ... :)