I have a CGridview and I want to print my CGridview page and I did it using the script.
Yii::app()->clientScript->registerScript(‘grabPageNo’, "
$('#getPageNum').on('click', function(event){
var pageNumber = $('.yiiPager > .selected > a').html();
callPDF(pageNumber);
});
");
But it is working only for the current page. I want to display CGridView results with values after sorted through filter.
hiral23790
(Hiraldarji237)
2
hello arvind
Actually I done export to pdf in my code with cgridview filter data.
for that i set the session in model’s search action, like,
$model_data = new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
$_SESSION['model_data']=$model_data;
return $model_data;
In $_SESSION[‘model_data’] you get filter data then you can use it in controller or view easily.
may be it helps you.
Thanks hiral. I am checking it.
Hiral, I am just getting an instance of CActiveDataProvider Object like this not the filtered data.
CActiveDataProvider Object
(
[modelClass] => ConsultationNew
[model] => ConsultationNew Object
(
[patient_name] =>
[patient_id] =>
[dob] =>
[gender] =>
[age] =>
[gender_desc] =>
[prefer_language_id] =>
hiral23790
(Hiraldarji237)
5
can you tell me please how you write your code?
hiral23790
(Hiraldarji237)
6
In Controller you can write like:
if(isset($session['model_data']))
{
$d = $_SESSION['model_data'];
$model = array();
if($d->data)
$model[]=array_keys($d->data[0]->attributes);//headers: cols name
else
{
$this->render('no_data_found',array('last_page'=>$_SERVER['HTTP_REFERER'],));
exit;
}
foreach ($d->data as $item)
{
$model[] = $item->attributes;
}
}
print_r($model);exit;
you can get output something like:
Array
(
[0] => Array
(
[0] => Userid
[1] => username
)
[1] => Array
(
[Userid] => 1
[username] => hiral
)
[2] => Array
(
[Userid] => 2
[username] => ravi
)
)
Thanks Hiral,
Although I got the answer, I am not clear about few things. Please tell me about the two things
what is $_SESSION[‘model_data’]?
and thanks a lot for giving me a solution. waiting for your answer. 
hiral23790
(Hiraldarji237)
8
welcome ,
it is the session variable.
see my previous post in that i set the session variable in model and then use it in controller.