chrisb34
(Chrisb)
October 28, 2011, 8:30am
21
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)),
),
............
marcovtwout
(Marco van 't Wout)
January 20, 2012, 8:45am
22
At least use headerHtmlOptions when setting column specific settings, you don’t need to set the width for each and every td.
urgent
(Urgent Programmer)
January 27, 2012, 4:41am
23
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
zeesniper
(Asghar Psh)
January 11, 2013, 6:06am
24
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;
}
Jimako
(Kizijimmi)
January 29, 2013, 7:29pm
25
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;'),
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.?
Scromish
(Migueldra)
November 22, 2013, 5:48pm
27
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.
edison8301
(Thomas Alfa Edison)
November 26, 2013, 1:33pm
28
Try using min-width in style instead of width.
So it will be like this
‘htmlOptions’=>array(‘min-width’=>‘200px’),
konapaz
(Konapaz)
November 17, 2014, 2:19pm
29
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