seanchen
(Gnsea)
December 8, 2012, 6:00pm
1
I have a grid view column name "record", I would like to click the record and pop up s new small window to display the detail of the record. I have read the classroom example a lot of times but i did not find the way
array(
'name'=>'Record',
'type' => 'raw',
'value'=>'CHtml::ajaxlink($data["record"],array("cnc/showrecord","id"=>$data["record_id"]),array(\'update\'=>\'#record_detail\'))',,
'htmlOptions'=>array('bgcolor'=>'yellow','padding'=>'0.5em'),
),
The above code works but doesn’t show in a new window.
Can someone help me? Thanks
konapaz
(Konapaz)
December 8, 2012, 10:34pm
2
check something like that
‘value’=>'CHtml::link(
array(
onclick'=>"MyWindow=window.open('http://www.yourlink.com','MyWindow','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=300,height=300'); return false;"
)
);',
seanchen
(Gnsea)
December 10, 2012, 12:38am
3
Thanks Konapaz! I tried, but it doesn’t work
dahuzizyd
(Dahuzizyd)
December 10, 2012, 8:00am
4
Now, the window.open is not recommend. Because many web browser’s default set is prevent it.
You can use CJuiDialog in Yii framework , for example:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
// additional javascript options for the dialog plugin
'options'=>array(
'title'=>'Dialog box 1',
'autoOpen'=>false,
),
));
echo 'dialog content here';
$this->endWidget('zii.widgets.jui.CJuiDialog');
// the link that may open the dialog
echo CHtml::link('open dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
?>
konapaz
(Konapaz)
December 10, 2012, 6:52pm
5
You have to be careful (I had too) with quotes and double quotes. (it was a little complicated)
The previous post was an example without checking, Now I tried it in my test project and works fine!
Just paste this code in your CGridview and you will see that works!
array(
'name'=>'Record',
'type' => 'raw',
'value'=>"CHtml::link('testlink',array('controller/action'),
array('onclick'=>'window.open(\'http://www.yourdomainlink.com\',\'mywindow\',\'status=1\'); return false;'
)
)",
),
",