Zii.widgets.grid.cgridview Sort Issues

I have a CGridview in that I have sortable columns for all except one. I have search table at the top. By default the gridview renders and when the users hit search the gridview renders based on the searched criteria and it works correctly. The issue is, when I did some search in the search form the grid populates values based on the search criteria and then if i sort the grid values, it populates the gridview with all the values which was loaded by default. but i think it should sort only for the search resulted value, it shouldnt populate all the search results. can anyone let me know how to fix the same? here is the code.

SEARCH FORM CODE




<div class="filtering">

	<table width="100%">

		<tr>

			<td><?php echo CHtml::label('Diversity Type', 'diversity_type'); ?></td>

			<td><?php echo CHtml::label('Safety Director', 'safety_directory'); ?></td>

			<td><?php echo CHtml::label('Residential Construction', 'residential_const'); ?></td>

			<td><?php echo CHtml::label('Payment and Performance Bonds', 'pay_and_perform_bonds'); ?></td>

		</tr>


		<tr>

			<td><?php echo CHtml::listBox('diversity_type', $selected_diversity_type, $diversity_types, array('multiple'=>'multiple', 'id'=>'dbe-filter') );?></td><td><?php echo  CHtml::textField('safety_directory',$_POST["safety_directory"]); ?></td>

			<td><?php echo CHtml::CheckBox('residential_const',$residential_const_checked_val, array ('checked'=>'checked','value'=>'0',)); ?></td>

	    	<td><?php echo CHtml::CheckBox('pay_and_perform_bonds',$pay_and_perform_bonds_checked, array ('checked'=>'checked','value'=>'0',)); ?></td>

			<td><?php  echo CHtml::submitButton('Filter', array('name'=>'Filter')); ?></td>

		</tr>

	</table>

</div>



CGRIDVIEW CODE




$dataProvider = new CArrayDataProvider(

        $model, array(

                'sort'=>array(

                'attributes'=>array('id'),

                'defaultOrder'=>array('id' => false),

        ),


		'sort'=>array(

        		'attributes'=>array(

					'company', 'name','my top vendors','no. of fans'

        	),

		),


                'pagination'=>array(

                'pageSize'=>10000,

        ),

));








 $this->widget('zii.widgets.grid.CGridView',array('dataProvider' => $dataProvider,

'cssFile' => Yii::app()->baseUrl . '/css/gridView.css',

'enablePagination' => false,


'columns' => array(

		array(

			'name' => 'name',

			'type' => 'raw',

			'value' => 'CHtml::link($data[name],array("user/details/$data[id]"), array("target"=>"_blank"));'

			),

		array(

			'name' => 'company',

			'type' => 'raw',

			'value' => 'CHtml::encode($data["company"])'

		),

		array(

					

			'name'=>'my top vendors',

			'type'=>'raw',

					'value'=>'CHtml::image(($data["my top vendors"]==0)?"images/star-white16.png":"images/star-gold16.png",$data["my top vendors"])', 

			'htmlOptions'=>array('style'=>'text-align: center;'),

			),

		array(

			'name' => 'no. of fans',

			'type' => 'raw',

					'value' => '$data["no. of fans"]',

			'htmlOptions'=>array('style'=>'text-align: center;'),

			),

		array(

			'name'=>'trades', 

					'value'=>'CHtml::link("View",array("view", "id"=>$data["id"]), array("id"=>$data["id"],  "class"=>"linkClass", "onclick"=>"viewTrades($data[id]); "))',

			'type'=>'raw',

			),

		array(

			'name'=>'', 

			'value'=>'CHtml::checkBox($data["id"], array_key_exists($data["id"], Yii::app()->session["project_vendors"]) ? true : false ,array("value"=>"checked","id"=>"cid_".$data["id"], "ajax"=>array("url"=>Yii::app()->createUrl("project/ajaxSaveVendors", array("id"=>$data["id"])),"type"=>"POST",


"success"=>"function(data){

			var cb=$(\'#cid_$data[id]\');

				cb.attr(\'checked\', !cb.is(\':checked\'));

				

			}",


) 


)

				


				)',

				


			'type'=>'raw',

			'htmlOptions'=>array('width'=>5),

			//'visible'=>false,




		),




				

	),

	


));




Hi,

you should look at ERememberFiltersBehavior.

If it doesn’t soluce the issue, you could not specify details of dataProvider in your gridview but in the model (sort and filter).