Let’s assume we have model with customers and car numbers.
I have the ordinary controller:
public function actionVieworders() {
...
$this->render('vieworders',array('model'=>$model));
}
Search function of model which returns CActiveDataProvider:
public function search() {
$criteria = new CDbCriteria;
$criteria->with[] = 'tcustomersrel';
$criteria->with[] = 'orderedproducts';
...
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'sort'=>array(
...
'pagination' => array(
'pageSize' => 20)
));
}
And gridview widget in the view:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'torder-grid',
'dataProvider'=>$model->search(),
...
'filter'=>$model,
'columns'=>$columns
));
As a result I see the correct number of rows in Summary as described in renderSummary of CBaseListView.php. In case of the following result rows count is 4:
±-----------------------+
| customer 1 | car 1 |
| customer 2 | car 2 |
| customer 2 | car 1 |
| customer 1 | car 1 |
±-----------------------+
In addition of this result I need to display the number of unrepeated rows by customers and car numbers. In above-mentioned case I want to get 3.
I failed trying to iterate through getData() in view, because getData() is displayed only data from current page in case of using CActiveDataProvider with pagination.
I failed trying to create criteria in model and pass count to view:
$newCriteria = clone $criteria;
$newCriteria->select='DateOfSend, IdCustomers, Time1, IdCar';
$newCriteria->group='DateOfSend, IdCustomers, Time1, IdCar';
var_dump($this->count($newCriteria));
I’m new in Yii and I didn’t know the correct way to organize a solution. After some research I didn’t get necessary answers.
Please could help me how to accomplish this.