How do I assign a class to <th> from within QDatagrid?

thread: 10 messages  |  last: a year ago  |  started: thursday, february 11, 2010, 5:47 pm pst


#1  |  kingwithin (San Francisco, CA) United States of America
Thursday, February 11, 2010, 5:47 PM PST
#2  |  Gaspar Attila (Odorheiu Secuiesc, RO) Romania
Friday, February 12, 2010, 7:41 AM PST

Here is the documentation for QDatagrid:
http://api.qcodo.com/index.php/QDataGrid/Properties

and QDatagridRowStyle:
http://api.qcodo.com/index.php/QDataGridRowStyle/Properties

Set css class to 'th' as follow:

<?php
   $this
->dtgTargets = new QDataGrid($this);
   
$this->dtgTargets->CellPadding 5;

   
$objHeaderStyle = new QDataGridRowStyle();
   
$objHeaderStyle->CssClass 'thclass';
   
$this->dtgTargets->HeaderRowStyle $objHeaderStyle;
   ....
?>
 

#3  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 9:07 AM PST

Great, I was looking for the api document, thanks.

#4  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 9:08 AM PST

Wait, how can I define the th for a specific column?

#5  |  comet7 (Georgia) United States of America
Monday, February 15, 2010, 10:30 AM PST

Is QDataGridColumn what you are looking for?  You can set CSS like this for a column:

$this->colId = new QDataGridColumn('Id', '<?= $_ITEM->Id; ?>', array('OrderByClause' => QQ::OrderBy(QQN::Category()->Id), 'ReverseOrderByClause' => QQ::OrderBy(QQN::Category()->Id, false)));
$this->colId->CssClass = 'myIdClass';

If you are only looking to set the class on the header row, you will need a condition for that cell.

#6  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 10:33 AM PST

Yeah, close, I used getColumn(n) and assigned cssClass to that...seems to be working, will keep you posted, thank you for your help!

#7  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 10:37 AM PST

Ugh, that didn't work, it only assigned a class for the <td> tag, but I cannot change the width that way....I am guessing it would need to be done at the <th> tag...?

#8  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 10:45 AM PST

So to be clear, when there is a table with columns 1-4, there is four <th> tags, each representing a column.  Each <th> tag I would like to assign a unique class so I can control the width of the column.  a) controlling the width in the controller doesn't seem to make sense; b) doesn't appear to work anyway.

Thanks...getting close, at least I can assign a class in the <td>....is there just a good example of the different ways to use?  

#9  |  kingwithin (San Francisco, CA) United States of America
Monday, February 15, 2010, 10:56 AM PST

I have been able to do the adjustents using css by removing all the styling I have for <th> and applying it at <td>....but I think it'd be cleaner if I could assign a class to a specific column for <th>....is there a way?  Seems to be a way to assign for all <th> or for <td> in a column (GetColumns) but not for <th> thanks for your help!

#10  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Tuesday, February 16, 2010, 11:05 PM PST

If you see the Changelog you'll see that more recent versions (starting in 0.4.3) added IDing of all table cells, which allow you to style individual columns using pure CSS.



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.