crazycoder Posted October 29, 2015 Share Posted October 29, 2015 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'), )) Quote Link to comment Share on other sites More sharing options...
Solution crazycoder Posted October 31, 2015 Author Solution Share Posted October 31, 2015 I added "style"=>"width:100%" in CHtml::textField htmlOptions and was able to change the width of column Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.