In the detail view of an event, I also display a list of subscribers (with name,email, attending columns) to that event, displayed in a gridview (which itself uses paging per 10 items).
Problem:
I want to be able to have filtering on top of that gridview, and also a way to e-mail that filtered result.
Even if the filtered result is more than 10 items, the button or link should call a mailto for all the filtered persons.
How can this be done? I know it must be possible, but I’m just in my first yii project and not experienced enough at the moment.
A paginated gridview doesn’t know the whole items, because the data provider has limited the returned results.
So I think that using a separated controller for the mailing function will make things simpler.
The filtering parameters are sent to the current controller in $_GET[‘Subscriber’] (the name is my guess). So why don’t you save it in the session and use it in the mailing controller?
A rough sketch might be …
public function actionSomething()
{
...
$model = new Subscriber('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Subscriber']))
{
$model->attributes = $_GET['Subscriber'];
Yii::app()->user->setState('SubscriberSearchParams', $_GET['Subscriber']);
}
...
}
public function actionMailToSubscribers()
{
$model = new Subscriber('search');
$model->unsetAttributes(); // clear any default values
$model->attributes = Yii::app()->user->getState('SubscriberSearchParams');
$dataProvider = $model->search_all(); // you will need a non-paginated version of search()
foreach($dataProvider->data as $subscriber)
{
...
}
...
}