Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnableHistory and Urls issue #1584

Closed
queirozfcom opened this issue Oct 19, 2012 · 4 comments
Closed

EnableHistory and Urls issue #1584

queirozfcom opened this issue Oct 19, 2012 · 4 comments
Assignees

Comments

@queirozfcom
Copy link

I have recently seen that it's possible to 'enableHistory' in a CGridView.

I use basic url rewriting and, for some reason, when I try and do pagination and sorting on a CGridView, even though the urls that get created are correct (I see that if I hover the mouse pointer over a pagination or a sorting link), when I click on it, my browser goes haywire.

Example:

url generated : http://localhost/sbce_backend/users/index/index/UsrsUser_page/2
(correct url)

upon clicking on the link:
http://localhost/sbce_backend/users/?/sbce_backend/users/index/index/UsrsUser_page/2=

I'm not sure this is a Yii issue at all but, when I removed 'enableHistory'=>true from my CGridView, everything started working again.

I've had this issue using:
Google Chrome Version 22.0.1229.94 on Ubuntu 11.04
Firefox 16.0.1 also on Ubuntu 11.04

Thanks you

FA

@ghost ghost assigned mdomba Oct 19, 2012
@mdomba
Copy link
Member

mdomba commented Oct 19, 2012

Why do you have "index/index" in the URL ?

Please post your url rules and the CGridView invocation.

@queirozfcom
Copy link
Author

index/index is because it is a controller with only one action, both named index. i generally call just index and, as there's only one action and it is the default action, that action gets called. you see index/index because that's the full route (controller and action) and it lives inside a module.

the relevant rules: (note that backend is a submodule of module users)

            'rules' => [
                '/users/index/index/<UsrsUser_page:\d+>' => '/users/index',
                '/users/index/index/<UsrsUser_sort:\w+>' => '/users/index',
                '/users/backend/<controller:\w+>/<id:\+>' => '/users/backend/<controller>',

cgridview invocation: //note that the widget i actually instantiate is not cgridview per se but a subclass thereof. the only difference is an extra attribute, namely 'enableBootstrapFix' which is just used for presentation purposes.

$this->widget('commonExtensions.widgets.MyCGridView.MyCGridView', array(
    'id' => 'users-grid',
    'dataProvider' => $model->search(),
    'enableBootstrapFix'=>true,
    'selectionChanged' => "function(id){window.location='" . Yii::app()->urlManager->createUrl('/users/view', array('id' => '')) . "' + $.fn.yiiGridView.getSelection(id);}",
    'filter'=>$model,
    'enableHistory'=>true,
    'columns' => array(
        array(
            'name' => 'id',
            'value' => '$data->id',
            'htmlOptions' => array(
                'style' => 'width:70px;'
            ),
        ),
        'username'
    )
));

@mdomba mdomba closed this as completed Oct 22, 2012
@mdomba mdomba reopened this Oct 22, 2012
@mdomba
Copy link
Member

mdomba commented Oct 22, 2012

I found the reason for this problem... It's in the $.deparam.querystring() method - cowboy/jquery-bbq#34

@mdomba
Copy link
Member

mdomba commented Oct 22, 2012

There was 2 problems here... first the above mentioned issue, and second the call url.substr(0, url.indexOf('?'))

When there is no ? in the path indexOf returns -1 so the actual call was url.substr(0, -1) that would return an empty string instead of the actual url.

@mdomba mdomba closed this as completed in ab4dfaa Oct 22, 2012
mdomba added a commit that referenced this issue Oct 22, 2012
Fixes #1584 CGridView enableHistory with "path" urlFormat
[ci skip]
cebe added a commit to cebe/yii that referenced this issue Nov 14, 2012
…t-relation-select

* 'master' of https://github.com/yiisoft/yii: (144 commits)
  Fixes yiisoft#1567 Added filterSelector to CGridView
  Renamed the CONTRIBUTING file to CONTRIBUTING.md so that GitHub effectively uses the Markdown syntax already present in the file when presenting it.
  Fixes yiisoft#1694 - doc fix
  Added issue number
  fixed whitespace issues introduced with yiisoft#851
  Updated CHANGELOG
  Fixes yiisoft#1584 same fix for CListView as already done for CGridView
  Fixes yiisoft#1344 same fix for CListView as already done in CGridView
  Fixes yiisoft#1104 same fix for CListView as already done for CGridView
  Fixes yiisoft#1676 - proper grouping when no group field is specified
  Added addPrimaryKey and dropPrimaryKey commands to CDbMigration class in response to enh req yiisoft#848
  [messages/ja] yii.php updated
  csfix - thx @resurtm
  typo in changelog
  Reverted PR yiisoft#1467 (Issue yiisoft#1465, fixes related issue yiisoft#1661)
  Reverted PR yiisoft#1662
  Better naming
  small update to documentation of filterAjaxOnly()
  Coding style fix
  Fixing bug yiisoft#1661
  ...

Conflicts:
	CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants