Display And Search The Fullname Consisting Of First,middle And Last Name

Hi there. Actually i want to display the fullname of student in CgridView. there is no attribute in the model named fullname. There are attributes like first name, middle name, last name. Using these i need to show full name. Now i have made a function which returns me the full name and then i use it in CgridView.

But the problem is that CGridview does not show filter field for the full name in CgridView. I thought to change the search like.


public function customsearch()

	{

            $fullname=$this->getFullName();

            $criteria=new CDbCriteria;

            $criteria->compare('id',$this->id,true);

            $criteria->compare('CONCAT(first_name,"",middle_name,"",last_name)',$this->fullname,true);

            return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

        }

Here is my controller action in which i render the view containing CgridView


 public function actionPromoteIndividual()

        {

             $student=new Student('customsearch');

             $student->unsetAttributes();

             if(isset($_GET['Student']))

			$model->attributes=$_GET['Student'];

             

            if(isset($_POST['GradeChange']))

		{

			$model->attributes=$_POST['GradeChange'];

			if($model->save())

				$this->redirect(array('view','id'=>$model->id));

		}

            else

            {

                $dataProvider=new CActiveDataProvider('Student',array(

                    'criteria'=>array(

                        'condition'=>'status_id=11'

                    ),

                ));

                $this->render('promoteIndividualList',array('student'=>$student,'dataProvider'=>$dataProvider));

          

            }

        }

Here is my view for GridView


<?php


$gridColumns = array(

//    array(

//        'name' => 'firstLetter',

//        'value' => '$data->class->standard_name',

//        'headerHtmlOptions' => array('style' => 'display:none'),

//        'htmlOptions' => array('style' => 'display:none')

//    ),

    array(

        'header' => 'Name',

        'value' => '$data->fullname',

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

    ),

    array(

        'header' => 'Status',

        'value' => '$data->status->key',

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

    ),

    array(

        'type' => 'raw',

        'header' => '',

        'value' => '"<a class=\"btn btn-danger\" href=\"".Yii::app()->createUrl("/dmo/GradeChange/promoteIndividual", array("id"=>$data->id))."\">Select</a>"',

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

        //'data-toggle'=>'modal',

        //'data-target'=>'#myModal'

        ),

       

    ),

);

   


$this->widget('bootstrap.widgets.TbExtendedGridView', array(

    'filter'=>$student,

    'type' => 'striped bordered',

    'dataProvider' => $student->customsearch(),

    'template' => "{items}",

    'columns' => $gridColumns,

));


?>

Now my question is how to make to filter the fullname in GridView. What i am doing wrong in my customSearch method?

Using the "getter" and "setter" method will be helpful in this case.

http://www.yiiframework.com/wiki/167/understanding-virtual-attributes-and-get-set-methods/