出于某种原因,我的过滤工作与我Yii网站上的寻呼机无法正常工作,我有以下视图,它使用 Yii Bootstrap TbGridView小部件来显示一些表格数据,并且能够过滤不同的选项,并在显示超过10行时显示寻呼机。
当我使用过滤时,它可以正常工作,但是如果我使用过滤然后导航到寻呼机的另一个页面(例如第2页或第3页),则$ _GET AJAX请求会中断。
当我在Mozilla irefox的新标签页中打开此AJAX请求网址时,它会显示以下内容:
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
问题是出于某种原因它正在替换字符串' =&'在' //'的网址中这导致它破裂。
我无法理解为什么会这样做,有什么想法吗?
<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>
答案 0 :(得分:0)
与CUrlManager关联的网址问题:如果urlFormat
设置为path
('urlFormat' => 'path')
,则默认为yii附加GET参数。要解决此问题,您可以将appendParams
设置为false
:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'appendParams'=>false,
'rules'=>array(
....
),
),