Many_Many Cgridview Filter

Good day guys I have here a cgridview column containing a concatenated keywords from MANY_MANY related table. My problem is that when i tried to filter a specific keyword on the column it loads back an individual word what I wanted to have is the same concat words filtered with the specific keyword search. Thanks in advance this is my codes:

this is my relations




public function relations()

	{

		return array(

			'shisDiagnosis' => array(self::MANY_MANY, 'ShisKeyword',

				'shis_diag_key(cons_id, key_id)'),

			'shisKeywords' => array(self::MANY_MANY, 'ShisKeyword',

				'shis_cons_key(cons_id, key_id)'),

		);

	}



my Search criteria in model




$criteria=new CDbCriteria;

$criteria->with=array('shisKeywords', 'shisDiagnosis');

$criteria->together = true;

$criteria->compare('shisKeywords.key_name', $this->concern, true);

$criteria->compare('shisDiagnosis.key_name', $this->diagnos, true);


return new CActiveDataProvider($this, array(

     'criteria'=>$criteria,

));



and the function that concats the keywords.




public function concatDiagnos()

  	{

    	$keys = $this->shisDiagnosis;

    	if($keys) 

		{

			$string = '';

			foreach($keys as $key) 

			{

				$string .= $key->key_name . ', ';

			}

			return substr($string,0,strlen($string)-2); 

    	}

    	return null;

  	}



cgridview column




array(

'header'=>'Diagnosis',

'name'=>'diagnos',

'value'=> '$data->concatDiagnos()',

),



Aren’t these the same?

Aren’t these the same?

Over all this looks like the ‘Tag’ search in the Blog tutorial. Maybe you could look at that for some inspiration. Also I have found that if I want to search via a relation, I had to create a Model attribute for example


public $shisDiagnosis_search;

and I used that in the GridView Filter line. Sorry I don’t have my dev machine with me so I can’t explain more. I just searched google for 'Yii gridview sort multiple tables" or something like that.

tnx for the reply

this is really working the problem is when i search in the field the concatenated data is being remove and it returns the single data before it was concatenated.