Hi
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
konapaz
(Konapaz)
November 15, 2012, 10:23am
2
prashant.tyagi:
Hi
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',
),
Keith
(Kburton)
November 15, 2012, 10:26am
3
You can use the labelExpression property, assuming that you’re using the CLinkColumn class.
thanks KonApaz and Keith For yout replay.the code has actually uses CButtonColumn class.can you tell me how can i do this with CButtonColumn class? tahnks
traprajith
(Traprajith)
November 16, 2012, 6:27am
5
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')
),
thanks Rajith for your replay
now i have a different problem, can i use ‘visible’ property with ‘CLinkColoumn’ class.thanks
konapaz
(Konapaz)
November 16, 2012, 9:37am
7
prashant.tyagi:
thanks Rajith for your replay
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’),
)
i mean ‘visible’ is not working in this code
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',
)
konapaz
(Konapaz)
November 16, 2012, 9:59am
9
prashant.tyagi:
i mean ‘visible’ is not working in this code
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
sorry for asking question again and again
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
traprajith
(Traprajith)
November 19, 2012, 7:49am
11
what u actually want? CButtonColumn? or CLinkColoumn ? u can set any values to the label, as u wish…
i want to use CButtonColumn as it is already applies to existing action.now how can i set ‘label’ of action a php variable as ‘label’ property of CButtonColumn doesn’t allow php variable for ‘label’