SOVLVED: Solution at end.
When using CGridView with a filter on a column the pagination doesn’t work once I have selected something via the filter. I get “Error 400. Your request is invalid.” popup when trying to change the page.
Causes the error:
Load the page
Change filter option
Change GridView page via pagination -> throws error
Doesn’t throw error:
Load the page
Change GridView page via pagination -> works smoothly
Only when I utilize the filter does it do this. Anyone have any idea what is happening?
Here is how I am setting up my filter
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'custom-list',
'dataProvider' => $dataProvider,
'filter' => MyModel::model(),
'columns' => array(
array(
'header' => 'Type',
'filter' => CHtml::dropDownList('MyModel[type]', '', MyModel::model()->getList()),
'name' => 'type'
)
array(
'header' => 'Name',
'name' => 'name'
)
)
)
I found the problem by going through the inspector looking at the url. Found I was setting the dataProviders pagination params which was causing a parameter to not be set for the action. So, to solve it I removed that 1 line of code for setting the pagination params (when I was utilizing building the GridView only by Ajax).