Yii Framework Forum: How to Change CgridView table class? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to Change CgridView table class? Rate Topic: -----

#1 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 28 December 2010 - 08:52 AM

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
Posted Image
0

#2 User is offline   frantic 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 172
  • Joined: 01-March 10
  • Location:Saint-Petersburg

Posted 28 December 2010 - 09:18 AM

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

0

#3 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 28 December 2010 - 09:23 AM

View Postfouss, on 28 December 2010 - 08:52 AM, said:

I can see in the source code of my page that CgridView has
<table class="items">
and I change this to
<table class="example">


How to do that?
thx


I think this is what you are looking for:
itemsCssClass

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
1

#4 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 28 December 2010 - 09:41 AM

View Postfrantic, on 28 December 2010 - 09:18 AM, said:

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


there are many classes:
<div class="keys" 
<div class="summary">
<table class="items">


I only want to rename for table
Posted Image
0

#5 User is offline   Trejder 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,197
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 28 December 2010 - 05:19 PM

View Postfouss, on 28 December 2010 - 09:41 AM, said:

there are many classes:
I only want to rename for table

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.
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#6 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 29 December 2010 - 04:00 AM

View PostTrejder, on 28 December 2010 - 05:19 PM, said:

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.


Thx.......
I didn't ename it again but I used the existing table class attribute (items) in my script and that work
Posted Image
0

#7 User is offline   Kuodo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 05-January 13

Posted 05 January 2013 - 05:58 AM

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

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>

2

#8 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 05 January 2013 - 07:41 AM

long time ago...... thanks anyway!
Posted Image
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users