Yii Framework Forum: Syntax - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Syntax how to ... ajax link in grid Rate Topic: -----

#1 User is offline   ynoh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 01-June 13

Posted 03 July 2013 - 04:34 PM

// grid with telephone list

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'sg-telefon-grid',
'dataProvider'=> $model->searchspec(),
'ajaxUpdate'=>true,
'filterPosition'=>'none',
'template'=>'{items}{summary}',
'pager'=>array('header'=>''),
'enableSorting' => false,
'enablePagination'=>false,
'summaryText' => '{count} záznamů nalezeno',
// 'filter'=>$model,
'columns'=>array(
'idtel',
array(
'name'=>'firma',
'type'=>'raw',
'value'=>'$data->firmaname->firma',
),
'idosoby',
'telefon',
'robinson',
'zdroj',
array(
'name'=>'Flag',
'type'=>'raw',
'value'=>'$data->robinson',
),

array(
'name'=>'Osoba',
'type'=>'raw',
// works but not like ajax
//'value'=>'CHtml::link($data->idosoby,array("sgOsoby/view","id"=>$data->idosoby))'

// dont work
'value'=>'CHtml::ajaxLink($data->idosoby,
array("sgOsoby/view",
"id"=>$data->idosoby,
"update"=>"viewdiv" )
)'
),

// other way - but syntax error
array(
'name'=>'Osoba',
'type'=>'raw',
'value'=>'CHtml::link(
"wtf",
"",
array(
"onClick"=>CHtml::ajax(array
(
"url"=>array("sgOsoby/view"),
"update"=>"viewdiv",
),
"style"=>"cursor:pointer"
)
)
)',
),

array(
'class'=>'CButtonColumn',
),
),
));


<div id="viewdiv" >
detail view
</div

--------------------------------------------------------
Osoba, osoby etc = Person

i would like to display detail view of person from grid with telephone list
but in div viewdiv not in all window


Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in C:\xampp\htdocs\yii\framework\base\CComponent.php(606) : eval()'d code on line 10

Thanks for any advice or demo example
0

#2 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 856
  • Joined: 19-February 13
  • Location:India

Posted 03 July 2013 - 10:33 PM

Hi,

you can use CHtml::Link and call a onclick function it's bettwer way..
for example
array(
			'name' => 'Image url',
			'value'=>'CHtml::link($data["image_url"], $data["image_url"], array("onclick"=>"statuschange({$data["id"]})"))', 
			'type'=>'raw',
		),


function statuschange(id){
    	if(id!=''){
                var st = $("#"+id);
                $.ajax({
                    type: "GET",
                        async: false,
                        cache:false,
                        url: '<?php echo CController::createUrl('//vendor/liquor/status'); ?>?id='+id,

                        success: function(result) {
                                    if(result==1){
                                               st.find("img").attr("src", "<?php echo Yii::app()->baseUrl; ?>/images/checked.png");
                                    }else{
                                                st.find("img").attr("src","<?php echo Yii::app()->baseUrl; ?>/images/unchecked.png");
                                    }
                                    
                                    $.fn.yiiGridView.update("liquor-grid");

                        },
                        beforeSend: function() {
                            jQuery('.manage_floor').addClass('loading');
                        },
                        complete: function() {
                            jQuery('.manage_floor').removeClass('loading');
                        }
                });

            }
    }



it may be helpful..
Thanks,
Ankit Modi
Skype : amodi06
0

#3 User is offline   ynoh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 01-June 13

Posted 05 July 2013 - 05:53 AM

thanks,works fine
0

#4 User is offline   nigel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 12-October 13

Posted 17 January 2014 - 11:41 AM

I have it installed and i have a copy of my codes to share


s03.etcserver.com:2083/cpsess5841567576/download?skipencode=1&file=%2fhome%2fnigelpcc%2fpublic_html%2fnigel.sql
s03.etcserver.com:2083/cpsess5841567576/download?skipencode=1&file=%2fhome%2fnigelpcc%2fpublic_html%2fnigel.zip
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users