Yii Framework Forum: Somehow I can't change the column size in CGridView - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Somehow I can't change the column size in CGridView Rate Topic: -----

#21 User is offline   Chris Backhouse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 04-August 11
  • Location:France

Posted 28 October 2011 - 03:30 AM

If you specify a custom filter on each column, you can include the size of the input box.

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'properties-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
        'columns'=>array(
		'ref',
		array(
                    'name'=>'type1',
                    'filter'=> CHtml::textField('type1',$model->type1,array('size'=>10)),
                    ),
	 ............

0

#22 User is offline   marcovtwout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 16-September 10
  • Location:Delft, NL

Posted 20 January 2012 - 03:45 AM

At least use headerHtmlOptions when setting column specific settings, you don't need to set the width for each and every td.
Yii-Environment Extension - Predefine configurations for use in different environments, like development, testing, staging and production.
NetBeans IDE and Yii projects - Short directions and general tips for managing a Yii application in NetBeans IDE
0

#23 User is offline   urgent 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 20-July 11

Posted 26 January 2012 - 11:41 PM

This really is more of a html problem than a CGridView problem. What you need is the table-layout:fixed; rule in your table tag, and overflow with a with rule in your td tag.

http://stackoverflow.com/questions/1057574/html-td-wrap-text
0

#24 User is offline   zeesniper 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-January 13

Posted 11 January 2013 - 01:06 AM

Neither of these worked for me...

At least solved by adding max-wdith to css in assets\ff2aa0ca\gridview\style.css

grid-view table.items th, .grid-view table.items td
{
	font-size: 0.9em;
	border: 1px white solid;
	padding: 0.3em;

	max-width: 115px;
}

Attached File(s)


0

#25 User is offline   Jimako 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 23-January 12
  • Location:Slovak Republic

Posted 29 January 2013 - 02:29 PM

View Postwsmits, on 29 April 2011 - 07:48 AM, said:

...
I need to figure out how to add a class to each individual filter textbox to let this resizing work.

Excuse my English.

I had the same problem. Using htmlOptions in grid helped only for columns without filter field.
I tried in my styles.css:
.grid-view table.items tr.filters td 
{
  width: 50px;
}

And it helped.
- I use bootstrap.widgets.TbGridView
- no width in 'htmlOptions' in Grid
- and 50px is minimum width of columns, real width depends propably on lenght of data. If I want more px, then I use width in 'htmlOptions'.
'htmlOptions'=>array('style'=>'width:100px;'),

0

#26 User is offline   rajesh chaurasia 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 12-January 13
  • Location:Mohali

Posted 15 June 2013 - 05:26 AM

hi friend if i write a comment like
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

than how to set it in grid column in a width is there is any option just to ignore wordwrap.?
0

#27 User is offline   Migue 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 20-June 11

Posted 22 November 2013 - 12:48 PM

Hello,

I think I found the problem is in the file bootstrap.min.css, looking uneditable string-input {width: 206px}., And change the size to 50px (for example) and go.

Hope you solve the problem.

Regards.
0

#28 User is offline   edison8301 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 29-December 11

Posted 26 November 2013 - 08:33 AM

Try using min-width in style instead of width.

So it will be like this

'htmlOptions'=>array('min-width'=>'200px'),
0

#29 User is offline   Kostas Apazidis (KonApaz) 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,380
  • Joined: 21-February 11
  • Location:Greece

Posted 17 November 2014 - 09:19 AM

View Postwsmits, on 29 April 2011 - 07:48 AM, said:

I think the problem is with the filter text boxes.
I have a similar problem in my gridview.
'id'=>'user-grid',
      'showSummary'=>false,
      'dataProvider'=>$model->search(),
      'cssFile' => Yii::app()->theme->baseUrl . '/css/gridView.css',
      'filter'=>$model,
      'emptyText' => 'Nog geen gebruikers aangemaakt',
      'columns'=>array(
         array(
          'name'=>'id',
          'htmlOptions'=>array('width'=>'40'),
        ),
        'first_name',
        'last_name',
        'email',


As you can see, I have added
'htmlOptions'=>array('width'=>'40'),
to the ID column. This doesn't seem to work because the text boxes in the filter row are not getting a smaller size.

When I remove
 'filter'=>$model,
then the resizing works well.

I need to figure out how to add a class to each individual filter textbox to let this resizing work.




In my case (with filter) I added

 'headerHtmlOptions'=>array('style'=>'width: 200px; display: block; padding: 16px 0;'),


or

'headerHtmlOptions'=>array('style'=>'padding: 0 50px;'),

And it works :)
Yii is the best php framework in the world!
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users