Hi ALL,
Trying to export the customers to CSV — the results filtered on grid. But I am getting ALL of them instead of the filtered.
You will be able to see this action on my controller:
/* Action Export To File
****************************************************************************/
public function actionExportToFile() {
//echo 'test';
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="report-customers-' . date('YmdHi') .'.csv"');
$model=new Customer('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Customer'])) {
$model->attributes=$_GET['Customer'];
}
$dataProvider = $model->search(false);
// csv header
echo Customer::model()->getAttributeLabel("Id").",".
Customer::model()->getAttributeLabel("Country_Id").",".
Customer::model()->getAttributeLabel("Gender_Id").",".
Customer::model()->getAttributeLabel("First_Name").",".
Customer::model()->getAttributeLabel("Last_Name").
" \r\n";
// csv data
foreach ($dataProvider->getData() as $data) {
echo "$data->Id, $data->Country_Id, $data->Gender_Id, $data->First_Name, $data->Last_Name \r\n";
}
exit;
}
/*******************************************************************************/
And I would like keep using AJAX on my filter — So How can I do that ? I am missing some POST/GET ? — I have followed a lot of stuff on the web but unfortunately still I couldn’t figured it out. ----------------- Thanks in advance for this help.
See attached files.
Cheers!