For some reason my filtering isn't working correctly inconjunction with the pager on my Yii site, I have the following view which uses the Yii Bootstrap TbGridView widget to display some tabular data and have the ability to filter on different options as well as display a pager if more than 10 rows are displayed.
When I use filtering it works ok, however if I use the filtering and then navigate to another page of the pager (e.g page 2 or 3 for instance) the $_GET AJAX request breaks.
When I open this AJAX request URL in a new tab in Mozilla irefox it displays the following:
The connection was reset
When I view the URL it generates I can see the problem with what is going on, below is the URL that is generated, with the 2nd URL being the correct URL structure that it should be for it to work.
// '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
This is the structure that I am expecting (this works when I manually past this into the browser)
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
The problem is for some reason it is replacing the string '=&' in the URL with '//' and this is causing it to break.
I cannot understand why it is doing this, any ideas?
<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>