Jump to content

Yii CGridView change column width for raw type cell


crazycoder
Go to solution Solved by crazycoder,

Recommended Posts

I am using Yii 1.1  CGridView with 'raw' cell type. The cell contains text field generated using CHtml::textField. Here I cannot change the width of the column using headerHtmlOptions or htmlOptions. Please help.

$this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'mbook-grid',
        'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',
        'dataProvider'=>$model->search(),
        'afterAjaxUpdate'=>'calcquantity',
        'enablePagination' => true,
        'pagerCssClass'=>'dataTables_paginate paging_bootstrap table-pagination',
        'pager' => array('header'=>'','htmlOptions'=>array('class'=>'pagination')),
        'columns' => array(

                            array(
                            'class' => 'CCheckBoxColumn',
                            'id'=>'project_estimate_id',
                            'htmlOptions'=>array('style' => 'display:none'),
                            'headerHtmlOptions'=>array('style' => 'display:none'),    
                            'selectableRows'=>2,
                            'value'=>'$data["project_estimate_id"]',
                            'checked'=>'true',
                            ),
                            array(name=>'description','value'=>'CHtml::textField("ProjectMBookGrid[description_".$data["project_estimate_id"]."]",$data["description"],array("class"=>"gridfield"))','type'=>'raw','header'=>'Description','headerHtmlOptions'=>array('style'=>'width: 5%;')),

                            array(name=>'length','value'=>'CHtml::textField("ProjectMBookGrid[length_".$data["project_estimate_id"]."]",$data["length"],array("class"=>"gridfield","style"=>"text-align: right"))','type'=>'raw','header'=>'Length','headerHtmlOptions'=>array('style'=>'width:5%')),
                            array(name=>'breadth','value'=>'CHtml::textField("ProjectMBookGrid[breadth_".$data["project_estimate_id"]."]",$data["breadth"],array("class"=>"gridfield","style"=>"text-align: right"))','type'=>'raw','header'=>'Breadth','htmlOptions'=>array('style'=>'text-align: right')),

   array(name=>'quantity','value'=>'CHtml::textField("ProjectMBookGrid[quantity_".$data["project_estimate_id"]."]",$data["quantity"],array("class"=>"gridfield","style"=>"text-align: right"))','type'=>'raw','header'=>'Quantity','htmlOptions'=>array('style'=>'text-align: right')),

            ),
                'htmlOptions'=>array('class'=>'grid-view table-responsive hide-x-scroll'),
    ))
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.