Basically, the odd and even css tags are not being applied to the grid.

Had to edit theme/theme.inc be adding the following:

$row_classes[] =  'row-' . (($row_number + 1) % 2 ? 'odd' : 'even');

Please see the following code snippet:

    if ($row_class_special) {
      $row_classes[] =  'row-' . (($row_number + 1) % 2 ? 'odd' : 'even');
      if ($row_number == 0) {
        $row_classes[] =  'row-first';
      }
      if (count($rows) == ($row_number + 1)) {
        $row_classes[] =  'row-last';
      }
    }

Testing working. Added some CSS to my custom theme CSS and good to go. Not sure why the row-first and row-last were included but the striping code was omitted.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Needs review » Needs work

Please always provide a patch because everything else is simply horrible to review.

polskikrol’s picture

Status: Needs work » Needs review

Please advise on the proper process for submitting patches? Anyway I can easly obtain the original file (as I did not save it before modifying)?

dawehner’s picture

Status: Needs review » Needs work
crutch’s picture

When using grid, and I have striping unchecked, striping remains. This is a theme issue and not views.

polskikrol’s picture

Dont think so, if you look at the code I had to add to theme/theme.inc (which is base drupal 7 file AFAIK), striping information was missing.

Just to clarify, this is when using Views, Format 'Grid', Show 'Fields'.

crutch’s picture

ah, I see what you saying.
---
my grid stack is looking like this with those settings

<div class="view-content">
<table class="views-view-grid cols-3">
<tbody>
<tr class="row-1">
<td class="col-1">
<div class="views-field views-field-title">
<span class="field-content">
...

in my case the grid striping setting has no effect because the table is using my custom theme css.

jberg1’s picture

Thank you. That helped me.
Please add to the next version.

haydeniv’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Status: Needs work » Needs review

This is still a problem in the latest version. This patch addresses it.

haydeniv’s picture

Helps to attach patch.

sterndata’s picture

Thanks for the patch. It worked for me.

haydeniv’s picture

Status: Needs review » Reviewed & tested by the community

Looks like this is ready to go unless we need a test for this tiny change.

silurius’s picture

I think the issue applies to both grids and tables. My table formats are not respecting the striping checkbox (first, even/odd and last classes only).

Lines 632-635 from the tables section of theme.inc:

  if ($row_class_special) {
    $vars['row_classes'][0][] = 'views-row-first';
    $vars['row_classes'][count($vars['row_classes']) - 1][] = 'views-row-last';
  }
silurius’s picture

Issue summary: View changes

Yeah, added some text highlighting within code tags, didnt work well.... correcting.

Jim Bacon’s picture

The patch in #9 applies striping classes of "row-odd" and "row-even" in the function template_preprocess_views_view_grid().

Meanwhile, it looks to me as if template_preprocess_views_view_table() applies striping classes of "odd" and "even" while template_preprocess_views_view_unformatted() applies striping classes of "views-row-odd" and "views-row-even".

Would it not be better to use the same class names for striping for Grid, Table and Unformatted outputs?

dawehner’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

Would it not be better to use the same class names for striping for Grid, Table and Unformatted outputs?

Changing the current classes in existing sites will cause avoidable damage. Can't we manually opt in for those classes?

I haven't seen stripes on grids often.

nerdoc’s picture

It's not about stripes. It's about odd/even.
I e.g. need these for adding float: left/right to images within these rows.

patrick.norris’s picture

DamienMcKenna’s picture

Status: Needs work » Needs review
tibezh’s picture

I've checked a patch from the #16 comment, looks good, but it will be better to have a little test.
A patch is attached.

joseph.olstad’s picture

looks great, has tests, the 100% for sure RTBC would be to have a tests only run which fails.

tibezh’s picture

Sure, you are right. Added a patch with tests only and an interdiff to check difference quickly.

Status: Needs review » Needs work
joseph.olstad’s picture

Status: Needs work » Reviewed & tested by the community

Great work!