0

我在这里为 eexcelview 实现了包装扩展:http://www.yiiframework.com/extension/toexcel/ 以导出我的 cgridview 数据。但是,此时,我只能弄清楚如何导出整个模型的所有记录。

这是我在模型控制器中的操作

    public function actionExcel()
{
    $fileName = 'Packaging_Metric_Data_Export_'. date("m-d-y");
    // Load data (scoped)
    $model = PackagingMetric::model()->findAll();;


        // Export it
    $this->toExcel($model,
        array(
        //'id',
        'date',
        'room',
        'lot',
        'country',
        'total_labor_hours',
        'total_run_time',
        'std_rate',
        ),
        $fileName,
        array(
            'creator' => 'Data Access Portal',
        ),
        'Excel2007'
    );
}

扩展页面上的注释说明使用与此类似的方法来实现此功能。但是,我似乎无法让它发挥作用。

$model = YourModel('search');
$model->type = 1; // This will filter out all the results whose type is 1 
$dataProvider = $model->search();

谁能阐明如何检索要由扩展导出的过滤后的 cgridview 结果?

4

1 回答 1

0

我没有使用过这个模块,但看起来你不是在寻找CGridView,而是某种数据提供者。

话虽如此,在上面的代码中,您有:

    $model = PackagingMetric::model()->findAll(); //removed extra ;

我不确定 PackagingMetric 是什么,但它看起来像是在扩展 CActiveRecord,并包含一个findAll()方法,因此您应该能够使该行类似于:

$condition = 'lot = 1';
$model = PackagingMetric::model()->findAll($condition);
于 2012-07-27T17:25:45.083 回答