Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:09:43+00:00 2026-06-01T01:09:43+00:00

I have a table with more than 5 columns , i want to hide

  • 0

I have a table with more than 5 columns , i want to hide some columns so that those column’s are shown only if some row is selected or its expanded .

Am using yiiframework’s CGridView , so how can i do this in that ?

Any help is appreciable ..

I want a feature like this, so that on expanding a particular record i can see the hidden column values

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:09:44+00:00Added an answer on June 1, 2026 at 1:09 am

    One way is :

     'columns'=>array(
            array(
              'name'=>'columnName',
              'visible'=>false
                ),
             )
    

    So you need to manipulate visibility attributes dynamically :

     'visible'=>$this->checkVisible() //custom function 
    

    sth like this depending on your requirement

    Edit (using ajax +jquery)

    example :views/user/admin.php

    .....
    .....
    <?php
    $toggleUDetails = <<<JS
     $('a.toggle').live('click',function(e){
        e.preventDefault();
    
        if(this.href.split('#')[1]=='loaded') return $(this).closest("tr").next('tr.toggle').toggle();
    
        trow=$(this).closest("tr");
    
       var ajaxOpts={type:"POST", url:this.href ,dataType:'json',success:function(data){
                $(trow).after(data.row);
          }
        };
    
       this.href=this.href+'#loaded';
    
       $.ajax(ajaxOpts);
    
      });
    JS;
    Yii::app()->clientScript->registerScript('toggleUD', $toggleUDetails, CClientScript::POS_READY); 
    
    $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'user-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'columns'=>array(
         array(
            'class'=>'CButtonColumn',
             'header'=>'Toggle Details',
              'template'=>'{toggle}',
                'buttons'=>array(
                  'toggle'=>array(
                            'label'=>'Details',                        
                                 'imageUrl'=>Yii::app()->request->baseUrl.'/images/expand.png',  
                                 'url'=>'Yii::app()->createUrl("user/getExtra", array("id"=>$data->id))',
                                 'options'=>array('class'=>'toggle',
    
                                          ),
                                   ),
                            ),
              ),
    
            'id',
            'username',
            'password',
            'email',
            array(
                'class'=>'CButtonColumn',
            ),
        ),
    )); ?>
    

    User Controller

    public function actionGetExtra($id){
            $model=User::model()->findByPk($id);
            echo json_encode(array('row'=> '<tr class="toggle"><td   colspan="6">'. $model->username.'</td></tr>'));
    
      }
    

    Enable access rights:

    array('allow', // allow authenticated user to perform 'create' and 'update' actions
                    'actions'=>array('create','update','getExtra'),
                    'users'=>array('@'),
                ),
    

    that much I can do you for . Remember to change the Java script function to toggle the image icon
    I have not done that

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written PLSQL program that generates table having usually more than 200 columns.
I have a table with more than 100 columns. I need to join it
So I have table with only two, long-ish columns. I want the display the
I have a table with more than a millon rows. This table is used
I have a large table (more than 10 millions records). this table is heavily
I have a table with more than 9 rows. If I do this :
I have a MyISAM table with more than 10^7 rows. When adding data to
I have a table with a lot of records (could be more than 500
Where I have more than one table in my database for use with (similar,
I have three tables in my DB (actually a few more than that) these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.