Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there a way to hide a row that is empty? When I tick the box "Hide Column if Empty" all the secondary rows disappear. I tried the field settings and chose "Hide if Empty" from the "No Results Bahaviour" area nothing happens.
Is there anyway I can hide empty columns while use this module?
Comment | File | Size | Author |
---|---|---|---|
#9 | hide-empty-rows-2066745-9.patch | 895 bytes | gruda |
Comments
Comment #1
MarMax CreditAttribution: MarMax commentedI have the same issue. The second row is not rendered when "Hide if Empty" of any field in the first row is ticked. I don't think this is a documentation problem, is it?
Comment #2
arancedisicilia CreditAttribution: arancedisicilia commentedI struggled a lot with weird behaviours, when I realized that hiding any of the fields was causing the secondary row not to be rendered.
Actually, I'm pretty sure this is a bug, but can't really nail it down.
Anyway, I think I narrowed it, since the problem seems to be in this piece of code:
and particularly in the "mysterious" line:
$empty &= empty($columns[$column]);
Commenting that line out does solve the problem for me.
Actually, I don't understand what that line's for, since both the header and column are removed a few lines later:
Not only the secondary row is rendered correctly, but the hidden fields are removed too from the view.
Maybe bojanz can help understand what's going on?
Comment #3
arancedisicilia CreditAttribution: arancedisicilia commentedI'm sorry for a terrible mistake I made on post #2, since the line I had doubt is evidently to check if the contents of the whole column are empty. So that line can't be removed, otherwise the column will be always hidden.
I hope to come up with something new. Sorry again!
Comment #4
timtk CreditAttribution: timtk commentedNot a problem thank for looking into arancedisicilia. Look forward to your solution
Comment #4.0
timtk CreditAttribution: timtk commentedSpelling correction
Comment #5
johnvComment #6
gruda CreditAttribution: gruda commentedThis patch will add the classes 'views-secondary-row--no-content' and 'hidden' to rows with empty fields. This will not work if twig debugging it turned on.
Comment #7
gruda CreditAttribution: gruda commentedComment #8
gruda CreditAttribution: gruda commentedFixed the paths.
Comment #9
gruda CreditAttribution: gruda commentedThis patch will add the classes 'views-secondary-row--no-content' and 'hidden' to rows with empty fields. This will not work if twig debugging is turned on. Re-rolled against the current branch.
Comment #10
johnvThanks, committed the patch to D8/D9-version.
Comment #11
johnvComment #13
johnvComment #14
johnvSetting to the version in which is was found. it will be fixed in curent -dev version and next stable version.
Comment #16
johnv