How to Change CgridView table class?


(Jsfousseni) #1

I can see in the source code of my page that CgridView has


<table class="items">

and I want to change this to


<table class="example">

How to do that?

thx


(Sanekmacros) #2

You may change the class of the parent div element:


$this->widget('zii.widgets.grid.CGridView', array(

        'htmlOptions' => array('class' => 'example')

So in css you may access the table with:


div.example table.items


(tri - Tommy Riboe) #3

I think this is what you are looking for:

itemsCssClass

/Tommy


(Jsfousseni) #4

there are many classes:




<div class="keys" 

<div class="summary">

<table class="items">



I only want to rename for table


(Tomasz) #5

There was a similar post about this lately. By me, if I’m not mistaken! :] I was asking how to change text align of all cells in CGridView’s table. Do some forum search to find it.

If I’m not mistaken, this is what you are looking for is not currently implemented. You can only change class of div surrounding table generated by CGridView, not class for table by itself.

But you can define ID for div surrounding table and then in your CSS file you can define styles like that:


#ID table {style}

This should apply your styling to any table inside parent element referenced by ID. And since there is only one table inside that particular ID, this shoud work for you.


(Jsfousseni) #6

Thx…

I didn’t ename it again but I used the existing table class attribute (items) in my script and that work


(Leon Kuo) #7

Since google showed this topic as the first result for “CGridView table class”, I’ll post it here:

[member=tri] was right. Thanks.

You can do it by defining the ‘itemsCssClass’ key as widget’s configuration.

So:


$this->widget('zii.widgets.grid.CGridView', array(

'itemsCssClass' => 'table-class',

'htmlOptions' => array('class' => 'example'))

gives you:


<div class="example"><table class="table-class"></table></div>


(Jsfousseni) #8

long time ago… thanks anyway!