CButtonColumn

The default css for gridview buttoncolumn has a fixed width of 60px. If I add another button to a gridview the button column will wrap. Is there a "simple way" to override the fixed with of CButtonColumn.

Thanks

amc

You can set the html options for the column in the grid view:




array(

  'class'=>'CButtonColumn',

  'htmlOptions' => array('style'=>'width:80px')

)



Komodo

Thanks.

That’s one option, however I was hoping there might be some easy way to make a global config change that would be the default for all grids - i.e. remove width all together and let the column autosize depending on how many icons it contains. I could change the grid css and remove the buttoncolumn width but that’s messy and is overwritten if the framework is updated.

amc.




array(

  'class'=>'MyCButtonColumn', // <<-- CHECK THIS LINE

  'htmlOptions' => array('style'=>'width:80px')

)



YOu can provide your own css class.

(And obviously you need to publish the css that contain that class)

And then, no matter if the css in the core is changed…

It is not possible to set the default width from a global config when using CButtonColumn. One way or the other, you have to change something in your grid views to achieve your goal.

You could extend CButtonColumn and use that instead:




array(

  'class'=>'MyCButtonColumn'

)



And what Pol meant (I think) was you could set the css-class in the htmlOptions and provide a css file with the included selector:




array(

  'class'=>'CButtonColumn',

  'htmlOptions' => array('class'=>'myCssClass')

)



Oops!!!

Komodo is right, that exactly what i want to say, sorry for the confusion!!!:P

Thanks guys, that’s cleared it up for me.

amc

Setting htmlOptions didnot worked for me, I also set headerHtmlOptions like this:


'headerHtmlOptions'=>array('style'=>'width:20px;'),

Santosh is correct - you can make the column wider, but it will not display any less than the default width - why is this? I have tried setting both width and min-width, to no avail.

You must set both htmlOptions and HeaderHtmlOptions