I am trying to generate a PDF. I need the selected Row from my CGridView for data generation.
I created this link to open the PDF in a new tab:
echo CHtml::link('Generate PDF', array('generatePdf'),
array('target'=>'_blank', 'class'=>'getParentId', 'onclick'=>'getData();'));
?>
This function gets me the selected row:
function getData(){
var myPK = parseInt($.fn.yiiGridView.getSelection("masterbegehung-grid"));
$.ajax({
'url':'<?php echo Yii::app()->createAbsoluteUrl("Masterbegehung/generatePdf")?>',
'type':'POST',
'data':{'parentID' : myPK,
YII_CSRF_TOKEN : $('input[name="YII_CSRF_TOKEN"]').val()},
});
}
The thing is, I cannot access the $_POST[‘parentID’] in my Controller action generatePdf().
It always says "undefined index".
What am I doing wrong there?
I think there is a problem with the url, cause I use the same action in my link and the post.
I tried the same with an ajaxlink, but I cant open a new tab, if this is possible with an ajaxlink?