enableHistory works great with with using default ?r=controller/action, however with urlManager configured as this:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
),
Pagination does not work anymore. Filtering, including history, works as expected on Page 1. But visiting another page breaks filters, and you stay on Page 1.
When selecting a new page in CGridView, the URL is updated to:
http://localhost/GridviewHistory/site/admin/?/GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin/Content_page/5//ajax/content-grid/Content_page/6//ajax/content-grid/Content_page/8//ajax/content-grid/Content_page/9//ajax/content-grid/Content_page/10//ajax/content-grid/Content_page/3//ajax/content-grid/Content_page/4//Content[name]//ajax/content-grid/Content_page/7=
But the page does not change. Note the questionmark in the URL which seems out of place.
Server: Apache (WAMP) on Windows 7
PHP version: 5.3.8
Browser: Firefox 14.01
Yii: 1.1.11
samdark
(Alexander Makarov)
August 15, 2012, 9:52am
2
Still there.
selecting multiple pages without applying filter results in url
http://localhost/GridviewHistory/site/admin/?/GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin//GridviewHistory/site/admin/Content_page/4//ajax/content-grid/Content_page/6//ajax/content-grid/Content_page/10//ajax/content-grid/Content_page/8//ajax/content-grid/Content_page/6//ajax/content-grid/Content_page/4//ajax/content-grid/Content_page/2//ajax/content-grid/Content_page/5//ajax/content-grid/Content_page/6//ajax/content-grid/Content_page/8=
samdark
(Alexander Makarov)
August 15, 2012, 11:49am
4
Do you have standard rules?
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
No, the urlManager is configured exactly as in the first post.
Gridview is also pretty much default:
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'content-grid',
'dataProvider' => $model->search(),
'enableHistory' => true,
'filter' => $model,
'columns' => array(
'name',
array(
'name' => 'published',
'value' => '($data->published == 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',
'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
),
array(
'class' => 'CButtonColumn',
'template' => '{delete}',
),
),
));
?>
samdark
(Alexander Makarov)
August 15, 2012, 12:00pm
6
Add default rules and it should help.
I’d rather not.
I want to implement this in an existing application and I cannot gaurentee every URL has been created with the createURL function. If I change the routes, I may break parts of the application.
Why doesn’t the pagination respect the rules?
samdark
(Alexander Makarov)
August 15, 2012, 1:17pm
8
It does respect rules. The problem that rules are telling it to append parameters instead of replacing them.
Can you suggest a work-around or something to resolve this? Or the bare minimum of rules to add?
samdark
(Alexander Makarov)
August 15, 2012, 2:12pm
10
If that is the bare minimum of rules to add to make this work I will try it. Thank you for your time
I do think this should be reflected in the documentation somewhere.
Adding the rules does not work!
I use the gridview in a module, a module which is two levels deep. Same error. Adding the rules only fixes it for use outside of the module.
I’ll file a bug report, functionality provided by a framework should “just” work. And if it doesn’t, it should be clearly described in the documentation.
enableHistory does not work with urlManager configured as
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
),
The pagination does not...
This bug has been fixed as of version 1.1.13, release candiate:
1246Bug #1584: Fixed CGridView and CListView urls when enableHistory was used with "path" urlFormat (mdomba)
https://github.com/yiisoft/yii/issues/1584
Thanks mdomba! Note issue 1246 should also be closed - https://github.com/yiisoft/yii/issues/1246