2

由于某种原因,我的过滤与 Yii 网站上的寻呼机无法正常工作,我有以下视图,它使用Yii Bootstrap TbGridView 小部件来显示一些表格数据,并能够过滤不同的选项以及显示如果显示超过 10 行,则分页器。

当我使用过滤时,它可以正常工作,但是如果我使用过滤然后导航到寻呼机的另一个页面(例如第 2 或第 3 页),$_GET AJAX 请求会中断。

当我在 Mozilla irefox 的新选项卡中打开此 AJAX 请求 URL 时,它会显示以下内容:

The connection was reset

当我查看它生成的 URL 时,我可以看到正在发生的问题,下面是生成的 URL,第二个 URL 是它应该工作的正确 URL 结构。

// 'broken' url     
http://dev.local/dev/shop/products/admin/ShopProducts%5Bproduct_name%5D//ShopProducts%5BemailNotification%5D//ShopProducts%5Bemail_user%5D//ShopProducts%5Bactive%5D//ShopProducts%5Binstant_win%5D//ShopProducts%5Bmulti_buy%5D//ShopProducts%5Bprice%5D//ShopProducts%5Bquantity%5D//ShopProducts_page/2/ajax/shopproducts-grid/hidden?ajax=shopproducts-grid

这是我所期望的结构(当我手动将其粘贴到浏览器中时,这有效)

http://dev.local/dev/shop/products/admin?ShopProducts%5Bproduct_name%5D=&ShopProducts%5BemailNotification%5D=&ShopProducts%5Bemail_user%5D=&ShopProducts%5Bactive%5D=&ShopProducts%5Binstant_win%5D=&ShopProducts%5Bmulti_buy%5D=1&ShopProducts%5Bprice%5D=&ShopProducts%5Bquantity%5D=&ShopProducts_page/2/ajax/shopproducts-grid/hidden?ajax=shopproducts-grid

问题是由于某种原因,它正在用 '//' 替换 URL 中的字符串 '=&',这导致它中断。

我不明白为什么要这样做,有什么想法吗?

<div class="row-fluid">
<div class="inner">
    <?php

    $data = $model->search();
    $hidden = (bool)CHttpRequest::getParam('hidden');

    $filterBtn = $this->widget('bootstrap.widgets.TbButton', array(
            'icon'          => 'filter',
            'size'          => 'small',
            'label'         => $model->paging ? 'View All' : 'View Less',
            'htmlOptions'   => array('class'=>'pull-right', 'style'=> 'margin:0 0 20px 10px;'),
            'url'           => $model->paging ? array("/dev/shop/products/admin/paging/0/hidden/{$hidden}") : array("/dev/shop/products/admin/hidden/{$hidden}")
        ), true);

    echo ($filterBtn);

        $this->widget('bootstrap.widgets.TbGridView',array(
            'id'            => 'shopproducts-grid',
            'type'          => 'striped bordered condensed',
            'dataProvider' => $data,
            'filter'        => $model,
            'template'      => '{summary}{items}{pager}',
            'template'      => 2 > ShopProductsController::PAGE_SIZE ?
                            '<div class="row-fluid"><div class="pull-right">'.$filterBtn.'</div><div class="pull-right" style="padding-top:5px;">{summary}</div></div>{items}<div class="row-fluid"><div class="pull-left">{pager}</div><div class="pull-right" style="margin-top: 20px;">'.$filterBtn.'</div></div>':
                            '<div class="row-fluid"><div class="pull-right">{summary}</div></div>{items}<div class="row-fluid"><div class="pull-left">{pager}</div></div>',
            'selectableRows'=>1,
            'columns'       => array(
                array(
                    'header'            => 'Image',
                    'value'             => 'CHtml::image($data->displayImageUrl, $data->product_name, array("class"=>"grid-image"))',
                    'type'              => 'raw',
                ),
                array(
                    'header'            => 'Name',
                    'name'              => 'product_name',
                    'value'             => 'CHtml::link($data->product_name,array("update","id"=>$data->getPrimaryKey()))',
                    'type'              => 'raw'
                ),
                array(
                    'name'              => 'emailNotification',
                ),
                array(
                    'header'            =>  'Notify User',
                    'name'              => 'email_user',
                    'value'             => 'CHtml::tag("i", array("class" => ($data->email_user == 1) ? "icon-font-ok" : "icon-font-remove"))',
                    'filter'            => CHtml::activeDropDownList($model, 'email_user', array(0 => 'No', 1 => 'Yes'), array('prompt' => 'All')),
                    'type'              => 'raw',
                    'headerHtmlOptions' => array('class' => 'align-center'),
                    'htmlOptions'       => array('class' => 'align-center'),
                ),

                array(
                    'header'            =>  'Active',
                    'name'              => 'active',
                    'value'             => 'CHtml::tag("i", array("class" => ($data->active == 1) ? "icon-font-ok" : "icon-font-remove"))',
                    'filter'            => CHtml::activeDropDownList($model, 'active', array(0 => 'No', 1 => 'Yes'), array('prompt' => 'All')),
                    'type'              => 'raw',
                    'headerHtmlOptions' => array('class' => 'align-center'),
                    'htmlOptions'       => array('class' => 'align-center'),
                ),
                array(
                    'header'            => 'Instant Win',
                    'name'              => 'instant_win',
                    'value'             => 'CHtml::tag("i", array("class" => ($data->instant_win == 1) ? "icon-font-ok" : "icon-font-remove"))',
                    'filter'            => CHtml::activeDropDownList($model, 'instant_win', array(0 => 'No', 1 => 'Yes'), array('prompt' => 'All')),
                    'type'              => 'raw',
                    'headerHtmlOptions' => array('class' => 'align-center'),
                    'htmlOptions'       => array('class' => 'align-center'),
                ),
                array(
                    'header'            => 'Multi-Buy',
                    'name'              => 'multi_buy',
                    'value'             => 'CHtml::tag("i", array("class" => ($data->multi_buy == 1) ? "icon-font-ok" : "icon-font-remove"))',
                    'filter'            => CHtml::activeDropDownList($model, 'multi_buy', array(0 => 'No', 1 => 'Yes'), array('prompt' => 'All')),
                    'type'              => 'raw',
                    'headerHtmlOptions' => array('class' => 'align-center'),
                    'htmlOptions'       => array('class' => 'align-center'),
                ),
                array(
                    'name'              => 'price',
                ),
                array(
                    'name'              => 'quantity',
                ),
                array(
                    'name'              => 'organisation_name',
                    'visible'           => ((user()->hasAuth(Group::GROUP_ADMIN, 'equal')) && (!user()->hasState('view_org'))),
                    'filter'            => CHtml::activeDropDownList($model, 'organisation_id', CHtml::listData(Organisation::model()->leaChildren, 'organisation_id', 'organisation_name'), array('prompt'=>'All Schools')),
                ),
                array(
                    'class'             => 'application.widgets.bootstrap.TbButtonGroupEx',
                    'delete'            => false,
                    'header'            => 'Actions',
                    'filter'            => CHtml::link('<i class="icon icon-remove"></i><br/>Remove Filters', array($this->defaultAction, 'clearFilters'=>1), array('class'=>'remove-filters')),
                    'template'          => '{view}{update}',
                    'headerHtmlOptions' => array(
                        'style'             => 'text-align:center; width:50px;'
                    )
                ),
            ),
        ));
    ?>
</div>

4

1 回答 1

0

与 CUrlManager 相关的 url 问题:默认情况下,如果urlFormat设置为yii,则path ('urlFormat' => 'path')附加 GET 参数。要解决此问题,您可以设置appendParamsfalse

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'appendParams'=>false,
    'rules'=>array(
                ....
    ),
),
于 2015-05-15T10:05:38.023 回答