I have a table(in a partial) that gets updated using ajax according to conditions set by checkboxes the problem is when the I set the checkbox and paginate it does not retain the values and shows the original results so the checkbox values are not retained after going to the next page. I was wondering if there’s a way to keep cgrid values when changing the page.
Model
if(isset($filters['isStudent'])) {
$isStudent= " user_status=2";
$sql .= " AND " . $showCleared;
}
Yii::app()->db->createCommand($sql)->queryAll();
Controller
$filters= $_POST;
$data = Users::model()->getUsers($filters);
// Gets the query count for pagination
$count = Yii::app()->db->createCommand('SELECT count(*) FROM ((' . $data . ') as alias)')->queryScalar();
$data = new CSqlDataProvider($data, array(
'totalItemCount' => $count,
'pagination' => array(
'pageSize' => 20
)
));
// updates the partial with new table data
$this->renderPartial('_usersTable', array('data' => $data),false,true);
View
$this->widget('CGridView', array(
'id' => 'table',
'htmlOptions' => array(
'class' => 'table table-striped pull-left',
'id' => 'users'
),
'dataProvider' => $data,
'columns' => array(
array(
'header' => 'Edit',
'id' => 'Edit',
'name' => 'Edit',
'value' => '"Edit User"',
'htmlOptions' => array(
'id' => 'edit',
)
),
array(
'header' => 'Name',
'id' => 'Name',
'name' => 'name'
),
array(
'header' => 'Login',
'id' => 'login',
'name' => 'login'
),
)
));