Hi, I’m having problem with the filter functionality in CGridview. The filter box doesn’t works at all. Nothing happens when i type something, and hit enter.
Here is the view code selectproducts.php::
<div id="shortcodes" class="page">
<div class="container">
<!-- Title Page -->
<div class="row">
<div class="span12">
<div class="title-page">
<h2 class="title">Available Products</h2>
</div>
</div>
</div>
<!-- End Title Page -->
<!-- Start Product Section -->
<div class="row">
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'products-grid',
'dataProvider' => $dataProvider,
'filter' => $dataProvider->model,
'ajaxUpdate' => TRUE,
'pager' => array(
'header' => '',
'cssFile' => false,
'maxButtonCount' => 25,
'selectedPageCssClass' => 'active',
'hiddenPageCssClass' => 'disabled',
'firstPageCssClass' => 'previous',
'lastPageCssClass' => 'next',
'firstPageLabel' => '<<',
'lastPageLabel' => '>>',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
),
'columns' => array(
'id',
array(
'name' => 'name',
),
'category',
'brand',
'weight_unit',
'price_unit',
'flavors',
array(
'name' => 'providers',
'value' => function($data) {
return '<div class="provider-label label label-info"><a href="http://www.'.$data->providers. '">'. $data->providers .'</a></div>';
},
'type' => 'raw',
),
),
));
?>
</div>
<!-- End Product Section -->
</div>
</div>
Here is the relevant action in ProductsController that is rendering this view. The $dataprovider variable in the view is a CActiveDataProvider object which holds the result of a conditional query.
public function actionDropdown() {
if (isset($_GET["Dropdown"])) {
$dropdownData = $_GET["Dropdown"];
$this->category = $dropdownData["category"];
$this->price = $dropdownData["price"];
}
// separate the price text into min and max value
$priceText = explode(" - ", $this->price);
$criteria = new CDbCriteria;
$criteria->compare('category', $this->category, true);
$criteria->addBetweenCondition('price', substr($priceText[0], 1), substr($priceText[1], 1), 'AND');
$dataProvider = new CActiveDataProvider('Products', array(
'criteria' => $criteria,
'pagination' => array(
'pageSize' => 20,
),
'sort' => array(
'defaultOrder' => 'price_unit, name',
),
));
$this->render('selectproducts', array(
'dataProvider' => $dataProvider,
));
}
And here is the Products model search() function ::
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('category',$this->category,true);
$criteria->compare('brand',$this->brand,true);
$criteria->compare('weight',$this->weight,true);
$criteria->compare('weight_unit',$this->weight_unit,true);
$criteria->compare('price',$this->price,true);
$criteria->compare('price_unit',$this->price_unit,true);
$criteria->compare('flavors',$this->flavors,true);
$criteria->compare('providers',$this->providers,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Now, when i hit enter in the filter box, i’m getting this error, which is logged in firebug
TypeError: $.param.querystring is not a function
[Break On This Error]
options.url = $.param.querystring(options.url, options.data);
In file jquery.yiigridview.js
Does anyone knows what is causing this error. I just can’t figure out what is causing this. And i also don’t know what modification should i do in jquery.yiigridview.js to fix this error.
Thanks in advance.
Maxx