Wednesday, June 15, 2011

how to set width in drupal table theme

$header = array('Content Name', 'Mandatory','Sequence');
...
...
...
$rows[] = array(
                      array('data'=>$contentTitle->title, 'width'=>'80%'),
                      array('data'=>$mandatory_check, 'width'=>'10%'),
                      array('data'=>$sequence, 'width'=>'10%'));

$data = theme('table', $header, $rows);
$form['contentByLevels'.$l]['result'] = array('#value'=>$data);

Look on this too..
We can use inline styles also in the table theming.  Like,

$rows[] = array(
            array('data'=>$contentTitle->title, 'width'=>'80%', 'style' => 'color:red;'),
            array('data'=>$mandatory_check, 'width'=>'10%', 'style' => 'font-family:arial;'),
            array('data'=>$sequence, 'width'=>'10%', 'style' => 'text-decoration:underline;'));

3 comments:

  1. Hello. this is something I've been looking for for a while. I'm a complete drupal noob and just can't figure it out. Could you give me exact step by step on how to perform this. My view is called what-where-when if that helps. I've seen a lot of examples of code but no one seems to want to tell you where exactly to put the code and/or are vague about the actual coding. Any help would be very much appreciated.

    ReplyDelete
  2. $rows[] = array('data' => $data, 'style' => 'word-break:break-all;',);

    ReplyDelete
  3. HI, just wanted to thank you for posting this, saved me a lot of time!

    ReplyDelete

Followers