I'm trying to work with a YII CGridview to display some data.
This is home my model search function looks like:
- /**
- * Retrieves a list of models based on the current search/filter conditions.
- * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
- */
- public function search()
- {
- $criteria=new CDbCriteria;
- $criteria->compare('ip',$this->ip,true);
- $criteria->compare('first_use',$this->first_use,true);
- $criteria->compare('last_use',$this->last_use);
- $criteria->compare('memberid',$this->memberid);
- $criteria->compare('countryid',$this->countryid);
-
- return new CActiveDataProvider(get_class($this), array(
- 'criteria'=>$criteria,
- ));
- }
And this is how my view looks like
- $this->widget('zii.widgets.grid.CGridView', array(
- 'id'=>'iplog-grid',
- 'dataProvider'=>$oIPLog->search(),
- 'filter'=>$oIPLog,
- 'summaryText' => 'showing you {start} - {end} of {count} logged Ips',
- 'columns'=>array(
- array(
- 'name'=>'ip',
- 'type'=>'raw',
- ),
- array(
- 'name'=>'first_use',
- 'type'=>'datetime',
- ),
- array(
- 'name'=>'last_use',
- 'type'=>'datetime',
- ),
- ),
- ));
Displaying the CGridview works, but I can't seem to get the filter on top of it to work. It sends the call and I don't get any error as reponse, it just returns the whole unfiltered data again..
Any clues?