0
votes

I want to add one extra field which is not part of model file. I want to add a textbox(user can type anthing in it) which should be matched with all the other values in CGridview and only matching ones should be displayed. But I cant understand how _search form provides value to CGridview. How can I feed the CGridview widget with the value of this new textbox. (This field is not part of model so default search functionality can not be used for it)

1
Can u post some code that u have tried ?? - Ninad

1 Answers

0
votes

Create a property with your custom field, create a method that uses the property to build a query that returns the records.

class Model extends CActiveRecord {

    public $globalSearch;

       public globalSearch()
       {
           $criteria = new CDbCriteria;
           // Conditions follow
           ...
           // Return models
           return new CActiveDataProvider($this, array(
            'criteria'=>$criteria,
               ));
       }
 }

 // Controller (or perhaps view if using a widget)

 $model = new Model;
 $model->globalSearch = 'parameter'

 $this->render('view', array('model'=>$model->globalSearch()));