. . .

How to change content of a cell in Grid View to a link

Published: October 4, 2010

On This Page

    If you want to link content of cell in Grid View to some page e.g In orders list, if you want customer’s name to be link that takes admin to customer’s detail page, change the columns of CGrid View as

    'columns' => array(
        'id',
        'user_id'=> array(
            'type'=>'html',
            'value' => 'CHtml::link( $data->user->name,
                           Yii::app()->createUrl( "admin/view", array("id"=>$data->user_id, "m"=>"users") ),
                           array("class"=>"facebox", "title"=>"View Customer Details") )',
            'header' => 'Customer'
        ),
        'product'=> array(
            'type'=>'html',
            'value' => 'CHtml::link( $data->product->name,
                           Yii::app()->createUrl( "admin/manage",
                                 array( "Orders[product_id]"=>$data->product_id, "m"=>"orders" ) ),
                           array( "title"=>"View All Orders for ".$data->product->name ) )',
            'header' => 'Product'
        ),
        array(
            'class'=>'CButtonColumn',
        ),
    )

     

    Don't forget to share this post

      Let's Build Digital Excellence Together


      • Cost Efficient Solutions.
      • Minimal Timelines.
      • Effective Communication.
      • High Quality Standards.
      • Lifetime Support.
      • Transparent Execution.
      • 24/7 Availability.
      • Scalable Teams.

      Join Our 200+ Happy Clients Across Globe


      Free Consultation.

        Do you need tech help of your startup/business? Experts from our team will get in touch with you.

        Please do not post jobs/internships inquiries here.