Yii Framework Forum: Dynamic Label In Cgridview - Yii Framework Forum

Jump to content

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

Dynamic Label In Cgridview Rate Topic: -----

#1 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 15 November 2012 - 05:08 AM

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
0

#2 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,312
  • Joined: 21-February 11
  • Location:Greece

Posted 15 November 2012 - 05:23 AM

View Postprashant.tyagi, on 15 November 2012 - 05:08 AM, said:

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',
),
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#3 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,520
  • Joined: 04-March 10
  • Location:UK

Posted 15 November 2012 - 05:26 AM

You can use the labelExpression property, assuming that you're using the CLinkColumn class.
0

#4 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 16 November 2012 - 12:22 AM

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
0

#5 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 20-April 11
  • Location:India

Posted 16 November 2012 - 01:27 AM

View Postprashant.tyagi, on 16 November 2012 - 12:22 AM, said:

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




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')
            ),

Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#6 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 16 November 2012 - 04:31 AM

thanks Rajith for your replay

now i have a different problem, can i use 'visible' property with 'CLinkColoumn' class.thanks
0

#7 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,312
  • Joined: 21-February 11
  • Location:Greece

Posted 16 November 2012 - 04:37 AM

View Postprashant.tyagi, on 16 November 2012 - 04:31 AM, said:

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'),
)
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#8 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 16 November 2012 - 04:54 AM

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',
)
0

#9 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,312
  • Joined: 21-February 11
  • Location:Greece

Posted 16 November 2012 - 04:59 AM

View Postprashant.tyagi, on 16 November 2012 - 04:54 AM, said:

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
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#10 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 18 November 2012 - 10:45 PM

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
0

#11 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 20-April 11
  • Location:India

Posted 19 November 2012 - 02:49 AM

what u actually want? CButtonColumn? or CLinkColoumn ? u can set any values to the label, as u wish..
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#12 User is offline   prashant.tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 14-September 12

Posted 19 November 2012 - 03:15 AM

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'
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