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

  • SEARCH
  • Home
  • 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 9018031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:25:02+00:00 2026-06-16T04:25:02+00:00

Q : how to create a custom column with custom buttons? I want to

  • 0

Q : how to create a custom column with custom buttons?

I want to create a grid view with cgridview as follow. How can I do?

Company Name | header 1.1 | header 1.2 | header 2.1 | header 2.2 |
header 3.1 | header 3.2

AAAA1 | [button] | [button] | [button] | [button] |
[button] | [button]

BBBB1 | [button] | [button] | [button] | [button] |
[button] | [button]

CCCC1 | [button] | [button] | [button] | [button] |
[button] | [button]

==================================================================================
update

This is my cgridview code

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'customer-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'customer_name',
        array(
            'class'=>'CButtonColumn',
            'template'=>'{select1} {select2} {select3} {select4} {select5} {select6} {select7} {select8}',
            'buttons'=>array
            (
                'select1' => array
                (
                    'label'=>'Send an e-mail to this user',
                    'url'=>'Yii::app()->createUrl("job/getjobno", array("c_code"=>$data->c_code))',
                    'imageUrl'=>Yii::app()->request->baseUrl.'/protected/assets/images/gridview/icon_select.gif',
                    'options'=>array('style'=>'width:10px; border:none'),
                    'click'=>'function(event) { 
                        $.ajax({
                            url:$(this).attr("href"),
                            dataType: \'json\',
                            success: function(data){
                                //alert(data.newjobno);

                                $("#Job_name").val(data.newjobno); 
                                //console.log(\'target tr: \' + target);
                                //$(target).find(\'.item-price\').val(data.newjobno);
                                $("#customerlist").dialog("close");
                            }
                        });                     
                        event.preventDefault();
                    }',
                ),      
            ),
        ),
        array(
            'type'=>'raw',
            'value'=>'$data->c_code',
            //'filter'=>array('style'=>'visible:none'), 
            'headerHtmlOptions'=>array('style'=>'width:0px; display:none; border:none; textdecoration:none'),
            'htmlOptions'=>array('style'=>'display:none; border:none;', 'class'=>'customer-id'),  
            'header'=>false,
            'filter'=>false,
        ),
    ),
)); ?>
  • 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-16T04:25:03+00:00Added an answer on June 16, 2026 at 4:25 am

    You almost got it right. Just that you will need more button columns, use a proper template for each column, and specify buttons for each column correctly:

    'columns'=>array(
        'customer_name',
        array(
            'header'=>'Header 1.1', // add headers this way
            'class'=>'CButtonColumn',
            'template'=>'{select1}', // only 1 button
            'buttons'=>array
            (
                'select1' => array
                (
                    // ... options for select1 button
                ),      
            ),
        ),
        array(
            'header'=>'Header 1.2', // add headers this way
            'class'=>'CButtonColumn',
            'template'=>'{select2}', // only 1 button
            'buttons'=>array
            (
                'select2' => array
                (
                    // ... options for select2 button
                ),      
            ),
        ),
        // ... and so on add the other button columns ...
        // ... rest of columns ...
    ),
    

    Incase you wanted all buttons in 1 column, you just have to add the button options within the buttons property:

    'columns'=>array(
        'customer_name',
        array(
            'class'=>'CButtonColumn',
            'template'=>'{select1}{select2}{select3}', // only 1 button
            'buttons'=>array
            (
                'select1' => array
                (
                    // ... options for select1 button
                ),
                'select2' => array
                (
                    // ... options for select2 button
                ),
                'select3' => array
                (
                    // ... options for select3 button
                ),      
                // ... and so on add the other button options ...
            ),
        ),
        // ... rest of columns ...
    ),
    

    Update: Just remember that whatever buttonId you mention in the template, use that buttonId to specify the button options:

    'class'=>'CButtonColumn',
    'template'=>'{buttonId1}{buttonId2}',
    'buttons'=> array(
        'buttonId1'=>array(
            // ... options ...
        ),
        'buttonId2'=>array(
            // ... options ...
        )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to create custom grid column with radio button in it. i have
I want to create custom button and I need it to be circle. How
I've created custom column(DataGridViewButtonControlColumn) and cell(ButtonControlCell) classes to hold System.Windows.Forms.Button controls. The buttons get
I want to provide custom paging in grid view. <asp:GridView ID=gvFirst runat=server AutoGenerateColumns=false AllowPaging=true
How to create Custom shaped buttons in c#: say triangular
Can i create custom touch events for iPhone?? will the device support for creating
How can I create custom variable in helper.php file set it right here and
I have a JTable where a user can create a custom report. They can
I have created a custom column header renderer for my AdvancedDataGrid which has a
Hi can anybody tell me how to create a custom made frame similar to

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.