Dynamic Label In Cgridview
#1
Posted 15 November 2012 - 05:08 AM
How can i show cgridview 'label' property by a php variable? for example
'contract1' => array
(
//'type'=>'raw',
'label'=>$model["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"],
'url'=>'Yii::app()->createUrl("contract/bonus", array("id"=>$data->id))',
'visible'=>'($data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"] != "")?$data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]:""',
),
thanks in advance
#2
Posted 15 November 2012 - 05:23 AM
prashant.tyagi, on 15 November 2012 - 05:08 AM, said:
How can i show cgridview 'label' property by a php variable? for example
'contract1' => array
(
//'type'=>'raw',
'label'=>$model["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"],
'url'=>'Yii::app()->createUrl("contract/bonus", array("id"=>$data->id))',
'visible'=>'($data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"] != "")?$data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]:""',
),
thanks in advance
Hi prashant.tyagi
check the below code instead of 'label'=>$yourphpvalue,
array(
'label' => $yourphpvalue,
'value' => $yourphpvalue2,
'type' => 'raw',
),
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
#3
Posted 15 November 2012 - 05:26 AM
#4
Posted 16 November 2012 - 12:22 AM
#5
Posted 16 November 2012 - 01:27 AM
prashant.tyagi, on 16 November 2012 - 12:22 AM, said:
array( 'class' => 'CButtonColumn', 'buttons' => array( 'add' => array( 'label' => Yii::t('Exam','Manage This Exam'), // text label of the button 'url'=>'Yii::app()->createUrl("/courses/exams/create", array("exam_group_id"=>$data->id,"id"=>$_REQUEST["id"]))', // a PHP expression for generating the URL of the button ) ), 'template' => '{add}', 'header'=>'Manage', 'htmlOptions'=>array('style'=>'width:17%'), 'headerHtmlOptions'=>array('style'=>'color:#FF6600') ),
Wiwo inc.
| Mobile: 919995504508
#6
Posted 16 November 2012 - 04:31 AM
now i have a different problem, can i use 'visible' property with 'CLinkColoumn' class.thanks
#7
Posted 16 November 2012 - 04:37 AM
prashant.tyagi, on 16 November 2012 - 04:31 AM, said:
now i have a different problem, can i use 'visible' property with 'CLinkColoumn' class.thanks
Try this
array(
'class'=>'CLinkColumn',
'htmlOptions'=>array('class'=>'my-no-display'), //with css .my-no-display{display:none}
//OR
'htmlOptions'=>array('style'=>'display:none'),
)
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
#8
Posted 16 November 2012 - 04:54 AM
array(
'class' => 'CLinkColumn',
'labelExpression'=> '"| $".$data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]." Reward"',
'urlExpression'=>'Yii::app()->createUrl("contract/bonus", array("id"=>$data->id))',
'visible'=>'(trim($data["wish_user"]["wish_user_profile"]["specialUser"]) != "") && (trim($data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]) != "") && ($data->wish_contract["contract_status"] ==0) && ($data->status ==0) && ((strtotime("today")-strtotime(date("d-m-Y", $data->created)))/86400)>3',
'htmlOptions'=>array(
'class'=> 'leadClass2',
)
#9
Posted 16 November 2012 - 04:59 AM
prashant.tyagi, on 16 November 2012 - 04:54 AM, said:
array(
'class' => 'CLinkColumn',
'labelExpression'=> '"| $".$data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]." Reward"',
'urlExpression'=>'Yii::app()->createUrl("contract/bonus", array("id"=>$data->id))',
'visible'=>'(trim($data["wish_user"]["wish_user_profile"]["specialUser"]) != "") && (trim($data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]) != "") && ($data->wish_contract["contract_status"] ==0) && ($data->status ==0) && ((strtotime("today")-strtotime(date("d-m-Y", $data->created)))/86400)>3',
'htmlOptions'=>array(
'class'=> 'leadClass2',
)
Check your conditions partially
(trim($data["wish_user"]["wish_user_profile"]["specialUser"]) != "") && (trim($data["wish_user"]["wish_user_profile"]["profilecampaign"]["reward"]) != "") && ($data->wish_contract["contract_status"] ==0) && ($data->status ==0) && ((strtotime("today")-strtotime(date("d-m-Y", $data->created)))/86400)>3'
test it by line disabled the others each time, may your logic cindition or field is invalid
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
#10
Posted 18 November 2012 - 10:45 PM
my problem is existing code uses CButtonColumn to show default actions.now i have to show label of one action by some database value with some conditions.can somebody tell me how can i set label to a database value?.i had add a CLinkColoumn ACTION and its label expression property works well but visible property not works well. can somebody tell me how to use visible property with CLinkColoumn class? or somebody can explain Ranjith's example?.thanks
#11
Posted 19 November 2012 - 02:49 AM
Wiwo inc.
| Mobile: 919995504508
#12
Posted 19 November 2012 - 03:15 AM