coy_coy
(Rexliterato)
October 16, 2012, 1:53pm
1
I’m having problem re-sizing the CGridview table. It always used up 100% width when I tried putting it into another table. I can’t find any related issue or solution with my problem. Any help is greatly appreciated. I am still new to this framework, please understand. Thanks.
Keith
(Kburton)
October 16, 2012, 2:02pm
2
What layout are you going for exactly?
coy_coy
(Rexliterato)
October 16, 2012, 2:07pm
3
either layout1 or layout2, same problem. If I’ll insert the cgridview into table row (<tr>) the header background will be white. All I wan’t is to resize the table only. Thanks.
reza.m
(Reza Mms)
October 16, 2012, 2:42pm
4
you can change gridview size by using css
CSS:
.grid-size
{
width: 500px !important;
height: 500px !important;
}
gridview
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'your-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
//columns
),
'htmlOptions'=>array('class'=>'grid-view grid-size',)
));
abennouna
(Abennouna)
October 16, 2012, 2:45pm
5
Can you post a screenshot of what you have now, and your view + layout codes, as well as a mockup of what you’re trying to achieve?
coy_coy
(Rexliterato)
October 17, 2012, 4:22am
6
I wanted to resize the gridview, the same size of the shaded table with button.
In my view code, I created a table as a container, then another table with border, and another table with button.
I didn’t create another table for the gridview because the headers messes up.
I just used the default layout1 code.
coy_coy
(Rexliterato)
October 17, 2012, 4:34am
7
you can change gridview size by using css
CSS:
.grid-size
{
width: 500px !important;
height: 500px !important;
}
gridview
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'your-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
//columns
),
'htmlOptions'=>array('class'=>'grid-view grid-size',)
));
I tried it, but it messes up the whole gridview. it overrides the whole css used by gridview.
reza.m
(Reza Mms)
October 18, 2012, 9:12am
8
If you don’t delete gridview default class (grid-view) it will work correctly
‘htmlOptions’=>array(‘class’=>‘grid-view grid-size’,)
also you can put your gridview in a div and set that div’s size by css
coy_coy
(Rexliterato)
October 18, 2012, 10:03am
9
If you don’t delete gridview default class (grid-view) it will work correctly
‘htmlOptions’=>array(‘class’=>‘grid-view grid-size’,)
also you can put your gridview in a div and set that div’s size by css
It worked!
Sorry I forgot to include the grid-view in the class.
Thank you very much!
and also, even if I set the width in each column, it changes it’s width when no results found when filtering. any idea?