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.
What layout are you going for exactly?
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.
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',)
));
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?
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.
I tried it, but it messes up the whole gridview. it overrides the whole css used by gridview.
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?