Customize Cgridview Rows By Some Custom Id

Gridview code


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'product-spec-grid',

	'summaryText'=>'',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'filter'=> $model1,

	'columns'=>array(


        array(

            'name'=>'category_id',

            'type'=>'raw', //because of using html-code from the rendered view

            //call the method 'gridMemberColumn' from the controller

            'value'=>array($this,'searchCat'),

        ),	

        array(

            'name'=>'spec_name',

            'type'=>'raw', //because of using html-code from the rendered view

            //call the method 'gridMemberColumn' from the controller

            'value'=>array($this,'searchSpec'),

        ),	

		array(

            'class'=>'CButtonColumn',

            ),

	//array('name'=>'spec_name','type'=>'raw','value'=>array($this,'getSpecname')),

	),

)); ?>



These are the two functions i have created in controller


	public function searchCat($data,$row)

	{

		$product_spec = new ProductSpec;

		

		$sql = "SELECT category_name from  category_description  where category_id='".$data->category_id."' order by category_id";

		$command=Yii::app()->db->createCommand($sql);

		$sql=$command->queryAll(); // execute a query SQL	

		foreach($sql as $s)

		{

			echo $s['category_name'];

		}	

	}

	

	

	public function searchSpec($data,$row)

	{

		$product_spec = new ProductSpec;

				

		$sql1 = "SELECT distinct GROUP_CONCAT(spec_name) as 'spec_name' from product_spec where category_id='".$data->category_id."' group by category_id";

		$command=Yii::app()->db->createCommand($sql1);

		$sql1=$command->queryAll(); // execute a query SQL	

		foreach($sql1 as $s1)

		{

			echo $s1['spec_name'];

		}

	}

4382

grid.png

I need to display only distinct rows but it will display all the records in productspec model.

How to eliminate the dublicate ones.

Need help from Yii Users…

I solved this problem by using query in CGridviews dataprovider.