Property CGridView.htmlOptions sets HTML options for viewer containing tag. Is there any way to set styles (not changing class) for table tag that is used to build CGridView?
For example, I want all my CGridView cells to be center-justified. The below does not work:
I’m trying to avoid changing CSS, whenever it isn’t strictly necessary.
Plus - I wanted to ask, if I’m not missing anything? For me personally, to was obvious that since there is a possibility to set styles (not class) for both column and main div container, that there also should be an option for modifying table tag contents. I don’t know like others, but I don’t see any reason for allowing direct (without touching CSS) modifying div styles and disallowing modifications to table tag in the same time. To opposite situation would be a bit more comfortable (I think most people want to change styles of table tag, not div), but still it would be best to have htmlOptions for both div and table.
Thanks! But this is solution for modifying all gridviews in particular project. I want to modify only one of them, in a particular view.
where zlecenia-grid is an id of gridview I want to modify.
But still, I think that there should be an option for modifying table itself styles, if we are talking in a matter that everything is (or should be) configurable in Yii.
CGridView and CGridColum are components and they have the htmlOption property… but the table as currently implemented is only for the items of CGridView…
so what you are asking is to have itemsHtmlOptions ? try to open a issue requesting it.
Anyway it’s a bad coding style to have inline CSS… it’s always better to make all display properties in CSS… look at that like you look at the MVC coding…
HTML is for the structure… CSS is how to display that structure…
as for not changing that is not a problem at all… in the main.php of your layout… after the default css includes… add one more css like
in the folder project\css create that file my.css and here you can write all you need for custom implementation… it will override the other as it’s the last one included…
Thanks! Since there is itemCssClass, and since in-lining CSS styles into HTML/PHP code is not so good ide, I think I’ll pass suggesting / requesting this feature. Thanks again for advices.