Skip to content

Loading…

EnableHistory and Urls issue #1584

Closed
queirozfcom opened this Issue · 4 comments

2 participants

@queirozfcom

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

@mdomba mdomba was assigned
@mdomba
Yii Software LLC member

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

Please post your url rules and the CGridView invocation.

@queirozfcom

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
@mdomba mdomba reopened this
@mdomba
Yii Software LLC member

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

@mdomba
Yii Software LLC member

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 in ab4dfaa
@cebe cebe added a commit to cebe/yii that referenced this issue
@cebe cebe Merge branch 'master' of https://github.com/yiisoft/yii into 1381-sta…
…t-relation-select

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

Conflicts:
	CHANGELOG
174a069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.