Actually in my grid view all works good! but when i go to another page then the search field not work & i have the reload the page again for search! here is my code:
https://stackoverflow.com/q/61699362/5672730
Controller:
public function actionAdmin()
{
$model = new Territory('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Territory']))
$model->attributes = $_GET['Territory'];
$this->pageTitle = 'TERRITORY SETUP';
$this->render('admin', array(
'model' => $model,
));
}
Model:
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('territory_name', trim($this->territory_name), true);
$criteria->compare('tso_code', trim($this->tso_code), true);
$criteria->compare('status', $this->status);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'pagination' => array(
'pageSize' => 100,
),
'sort' => array(
'defaultOrder' => 'area_id, territory_name, tso_code ASC',
),
));
}
View:
$this->widget(‘ext.groupgridview.GroupGridView’, array(
‘id’ => ‘territory-grid’,
‘dataProvider’ => $model->search(),
‘filter’ => $model,
‘mergeColumns’ => array(‘area_id’),
‘cssFile’ => Yii::app()->theme->baseUrl . ‘/css/gridview/styles.css’,
‘template’ => “Click on titles to re-arrange order (Ascending/Descending){pager}{summary}{items}{pager}”,
‘columns’ => array(
‘territory_name’,
‘tso_code’,
)
));