A common desire with the grid style is to have columns display with equal widths to have a nice even grid. Table cells expand depending on their content, so if you have, say, different lengths of node titles in your results, it can get uneven easily.

The td tags have column counts on them, but there's no way to generically know how many columns are in a table, unless you target the specific view. If the table tag had a class like "cols-4" on it, it would be easy to do a table.cols-4 td { width: 25%; } to even out the columns.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
342 bytes

Here is a patch. If this patch is not accepeted you can still do this same in your own theme_preprocess_views_view_table

merlinofchaos’s picture

Status: Needs review » Fixed

Simple enough. Committed to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

doublejosh’s picture

Nice. Been wanting to suggest this for a while. Can't wait for it to get into the next release.

doublejosh’s picture

Status: Closed (fixed) » Active

This seems to have been a patch for table style not grid style. Suppose the table one needed it too :)

Thought I could add this to line 470, but it seems $vars['classes'] is not used on this preprocess function?

$vars['classes'] .= ' cols-'. count($vars['rows']);
dawehner’s picture

Shouldn't be this part of http://drupal.org/node/714836 ?

dboulet’s picture

Title: Add class with number of rows to table tag in grid style » Add class with number of columns to table tag in grid style
Status: Active » Needs review
FileSize
1.42 KB

Why are we counting rows to generate a class called "cols"? The patch that was committed doesn't facilitate the requested feature at all.

merlinofchaos’s picture

Assigned: Unassigned » dawehner

dereine, can you look at this? I remember seeing something like this when I was messing with semantic views patch, and it felt like the cols- counting in general was counting rows, not columns, but I'm not totally sure.

dboulet’s picture

FileSize
43.63 KB
$vars['class'] .= ' cols-'. count($vars['rows']);

It's definitely counting rows.

merlinofchaos’s picture

Because of the semantic views patch I suspect we need separate patches for 2.x and 3.x

merlinofchaos’s picture

Status: Needs review » Fixed

Committed fix to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.