Hi. I want to show every message written to the logged in user in a gridview. I have 83 messages in "Mensaje". only 4 belongs to current user. The gridview shows 1-10 from 4 messages in the summary and 10 messages y the data. If i sort by id column u can notice that gridview load all 83 messages. Any help?? This is the code fragment.
but there is no id_usuario in “Mensaje” class. I use ‘destinatarios’ (a many_many relation) to get trought that property. That’s why i use my own dataprovider.
In which case I think I would suggest that you make a custom search function in your Mensaje model, that is an exact copy of the normal search function, but also either takes a CDbCriteria as parameter (which would allow you to preset the id_usuario when calling it, or that automatically includes it somehow.
For example:
/**
* 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) {
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria->compare('id',$this->id,true);
$criteria->compare('name',$this->name,true);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}