Hi All,
I am implementing a filter analytics and my filter criteria includes, startdate, enddate, manager, country, region etc.
I have used CActiveDataProvider to collect the filtered data and CGridView to render the filtered result.
But i am having problem when i try to look next page in cgridview, it looses all the conditions on the data that i have applied and show me all the data.
My Model
public function process()
{
$criteria = new CDbCriteria;
$criteria->with[] = 'prospect';
$criteria->together = true;
$managercond = null;
if($this->managers) {
$size = count($this->managers);
for($i = 0; $i < $size; $i++) {
if(!is_numeric($this->managers[$i])) {
throw new CHttpException(400, 'Invalid values');
}
if($i) {
$managercond .= 'OR ';
}
$managercond .= ' (t.assignedto='.$this->managers[$i].')';
}
$criteria->addCondition($managercond);
}
$calendercond = null;
if($this->ts_calendarBegin) {
$calendercond = 't.tscreated >= '.$this->ts_calendarBegin;
$criteria->addCondition($calendercond);
}
$calendercond = null;
if($this->ts_calendarEnd) {
$calendercond = 't.tscreated <= '.$this->ts_calendarEnd;
$criteria->addCondition($calendercond);
}
return new CActiveDataProvider('Query', array(
'criteria' => $criteria,
'pagination' => false,
));
}
My Controller
public function actionManagersearch()
{
$model = new Managersearchform;
$dataProvider = $model->process();
if(isset($_POST['Managersearchform'])) {
$model->attributes = $_POST['Managersearchform'];
if($model->validate()) {
$dataProvider = $model->process();
$mode = $_POST['Managersearchform']['submit'];
}
}
$this->render('managersearchform', array('model' => $model,
'dp' => $dataProvider
));
}
My View
<div class="viewgrid">
<?php
if ($dp) {
echo "count = " . count($dp->getData());
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'query-grid',
'dataProvider'=>$dp,
'ajaxUpdate' => 'false',
'enableSorting' => false,
'columns'=>array(
array(
'name' => 'id',
'htmlOptions' => array(
'style' => 'width:15px;',
),
),
array(
'header' => 'Created',
'value' => 'date("d/m/Y(H:i:s)", $data->tscreated)',
'htmlOptions' => array(
'style' => 'width:35px;',
),
),
array(
'name' => 'priority',
'htmlOptions' => array(
'style' => 'width:20px;',
),
),
array(
'header' => 'Status',
'name' => 'querystate',
'htmlOptions' => array(
'style' => 'width:15px;',
),
),
array(
'header' => 'Prospect',
'value' => '$data->getProspectFullName()',
'htmlOptions' => array(
'style' => 'width:25px;',
),
),
array(
'header' => 'Country',
'value' => '$data->prospect->country->name',
'htmlOptions' => array(
'style' => 'width:15px;',
),
),
array(
'header' => 'Description',
'value' => 'IIUtils::shorten($data->description)',
),
array(
'class'=>'CButtonColumn',
'template'=> '{view}',
'htmlOptions' => array(
'style' => 'width:15px;',
),
),
),
));
}
?>
</div>
I am not showing the whole view, only showing the cgridview part.
Please help
Thanks in advance