This is a fairly benign issue but I thought I would mention it as it will prove frustrating if it pops up out of the blue.

I have a view block that uses a Grid format with 4 columns and a set of filters that will display anywhere from 2 to 32 items. The Grid settings are default except for being 4 columns wide.

The issue is that although the table is set to have 4 columns, if the number of items to return are less than 4 (ie: 2) the table will only produce that number of columns. In my case one filter produces two items so the table that was set to span 100% with 4 td elements with widths of 25% ended up a table at 100% and only 2 td elements. Not the end of the world and I was able to adjust the CSS stylesheet to make up for it but this is a different behaviour from the 7–3.3 version and may trip someone else up.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

couturier’s picture

Yes, it seems several people are having problems with some of the settings being undone during the upgrade from 3.3 to 3.4. You might refer to these other two issues and close this one if any of that information helps solve your problem. These two issues below may not be exactly the same as what you are facing, but they could be related.

Update to 7.x-3.4 un-sets the boolean operator in filters

Upgrade is cancelling boolean operator settings

awasson’s picture

Nope, different issues. I commented on those when I ran across those last night and resolved them in one of my sites.

This is entirely an issue with the way the HTML for the table is outputted and I believe 7.x–3.4 ignores the checkbox setting for "Fill up single line" which is on in this case and on by default.

awasson’s picture

Well 7.x–3.5 is out and fixes the boolean bug but the Grid view is still not outputting the correct number of TD's.

dawehner’s picture

awasson’s picture

@dawehner: Do you think so? I'm not sure that it is.

This is a new behavior that only began with the 7.x–3.4 / 7.x–3.5 updates. 7.x–3.3 was outputting the correct number of TD elements regardless whether there was data or if they were empty cells.

Thanks,
Andrew

Ace Cooper’s picture

Title: Update from 7.x–3.3 to 7.x–3.4/7.x-3.5 : Grid format disregards preset number of columns » Update from 7–3.3 to 7–3.4; Grid format disregards preset number of columns
Version: 7.x-3.5 » 7.x-3.4
Component: User interface » Miscellaneous
Assigned: Ace Cooper » Unassigned
Status: Needs review » Active
FileSize
56.21 KB

Happens to me as well - Views 3.5 ignores the "Fill the last row" setting for a single row.
To better demonstrate it, see some screenshots:
1. Views respects "Fill up last row" setting when there are several rows.
2. Views ignores "Fill up last row" setting with only single row of results.

awasson’s picture

Yes, the second JPG illustrates exactly the issue I ran into. The outputted code should generate a table with 4 TD elements but only generates 2 which forced me to go in and change the CSS as a temporary work-around.

The code difference is as follows:

<!-- correct output with Views 7.x–3.3 -->
<table class="views-view-grid cols-4">
  <tbody>
	<tr class="row-1 row-first row-last">
      <td class="col-1 col-first">
          <!-- A series of fields depicting content -->
      </td>
      <td class="col-2">
          <!-- A series of fields depicting content -->
      </td>
      <td class="col-3">    </td>
      <td class="col-4 col-last">    </td>
    </tr>
  </tbody>
</table>
<!-- Incorrect output with Views 7.x–3.4 / 7.x–3.5 -->
<table class="views-view-grid cols-4">
  <tbody>
	<tr class="row-1 row-first row-last">
      <td class="col-1 col-first">
          <!-- A series of fields depicting content -->
      </td>
      <td class="col-2 col-last">
          <!-- A series of fields depicting content -->
      </td>
    </tr>
  </tbody>
</table>
Ace Cooper’s picture

Title: Update from 7–3.3 to 7–3.4; Grid format disregards preset number of columns » Update from 7.x–3.3 to 7.x–3.4/7.x-3.5 : Grid format disregards preset number of columns
Version: 7.x-3.4 » 7.x-3.5
Component: Miscellaneous » User interface
Assigned: Unassigned » Ace Cooper
FileSize
529 bytes

To make Views correctly fill up a single row I edited the views/theme/theme.inc line 692 (Views 3.5):

// Fill up the last line only if it's configured, but this is default.
      if (!empty($handler->options['fill_single_line']) && count($rows)) {

and changed it to:

// Fill up the last line only if it's configured, but this is default.
      if (!empty($handler->options['fill_single_line'])) {

Attached below you will find a simple patch for this feature. Voilà!

P.S. "If you want something done well - do it yourself" Mr.Zorg, 5th Element.

Ace Cooper’s picture

Status: Active » Needs review
Bitou Deouf’s picture

edit: nevermind...

Bernsch’s picture

Title: Update from 7–3.3 to 7–3.4; Grid format disregards preset number of columns » Update from 7.x–3.3 to 7.x–3.4/7.x-3.5 : Grid format disregards preset number of columns
Version: 7.x-3.4 » 7.x-3.5
Component: Miscellaneous » User interface
Assigned: Unassigned » Ace Cooper
Status: Active » Needs review

Patch from #8 works for me!
Thanx!

MustangGB’s picture

Ace Cooper’s picture

Title: Update from 7.x–3.3 to 7.x–3.4/7.x-3.5 : Grid format disregards preset number of columns » Grid format disregards "number of columns" option for a single line of results
Status: Needs review » Fixed

Changed title to better describe the problem and closed the issue.

I dropped the version description:
Update from 7.x–3.3 to 7.x–3.4/7.x-3.5
since version is tagged within issue.

I can not imagine a case, where we would like an item from single line of results have a different width than items from multiple lines.
If someone can produce such a usecase - feel free to reopen this issue and we will have to add a corresponding checkbox to the grid formater options.

awasson’s picture

@Ace Cooper: Thanks for adjusting the title and putting together the patch in #8 but shouldn't we keep the issue open until it has been committed to the next views update?

MustangGB’s picture

Status: Fixed » Needs review

If you don't wish to work on the issue please unassign yourself, but this has not been committed so is not yet fixed.

Ace Cooper’s picture

Just stumbled on a bug, related to #12.
When content in grid is vertically aligned - single line of results is still not filled: screenshot.
Will look into it later, my content will fill up the line for sure.

P.S. And another strange behaviour when the line is almost finished, but two nodes are missing: screenshot
O O O O O O O
O O O O O

caktux’s picture

Thumbs up for #8, thanks!

ditcheva’s picture

FileSize
54.02 KB
56.13 KB

I'm not sure that #8 solves the original issue reported. It does not for me, in any case.

I have a simple view that displays images (nothing else), and the grid settings are as follows:
Grouping: none
Number of columns: 4
Alignment: Horizontal
Fill up single line: checked

In Firefox, the columns are never what I specify, but simply fill up the entirety of the page width. In IE, it's even worse with the images running past my page. Images are attached!

Any other ideas (other than #8) for what may be causing this?

mengi’s picture

Having the same issue as OP and #8 patch works for me. Thanks!

lightstring’s picture

#8 patch helped me too. In case it doesn't break any functionality and has no negative effects, will it be commited so one will not need to hardcode again after updating the module?

Bernsch’s picture

@ditcheva

Try thise one in your CSS file:

.view-galleryname td {
   width: 20%;
   padding-bottom: 2em;
}
ditcheva’s picture

Thanks, @Bernsch, but this does not fix my issue in IE (view still looks exactly as in my screenshot), and in Firefox, it actually stacks my tds in a single column vertically.

It seems that the patch fixes the issues for everybody else on this thread, so I may just be missing something. On the other hand, if anyone else continues to experience issues even when they apply the single line change in #8, speak up. :-)

For the moment, as a work-around, I have modified my grid views to instead use the 'unformatted list' display, because at least that does not run off the page in IE, even though you cannot specify the number of columns.

klaasvw’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Status: Needs review » Reviewed & tested by the community

The patch from #8 also fixed the issue for me.

I'm setting this issue to RTBC:

- Several people already replied it works for them.
- A similar issue (#12, #16) that was not fixed has been reported separately and will require a different fix.
- The issue from #22 is most likely a client side issue unrelated to his fix.

queenvictoria’s picture

Patch in #8 fixes the issue for me. (Horizontal alignment)

Rafix’s picture

Hi everybody!

The pach in #8 didn't fixed the issue for me. It get closer the fields each other in the columns but never fixed it totally.

I am ussing a responsive theme (I don't know if have something to do) Pixture Reloaded (adaptive theme).

Do you know something new about this issue?

Thanks!

dawehner’s picture

@Rafix
Have you tried the same problem with a theme provided by drupal core? If it's working on that one, we are fine, and this is just a problem of this custom/other contrib theme. Feel free to post an issue on one of these queues.

Rafix’s picture

FileSize
16.07 KB
22.58 KB

@dawehner
Thank you for your answer. I've tried in Bartik and I think that is happening the same thing. I attach jpg with both themes in order you can see it.
Any answer will be great! Thank you again.

*I edit for further information.
In the attached jpg files I am using the patch in #8

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

So I guess the status can't be rtbc anymore, sorry

jcsnyder’s picture

For me, a combination of patch in #8 and table-layout:fixed; applied to table did the trick. Thanks a ton everybody!

pfrenssen’s picture

rrrob’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
36.5 KB

Issues #18 & #25 above most likely due to CSS. Please provide incorrect HTML if you believe my statement is in error.

I have tested this patch with the settings as per the attached screenshot.

Resetting this to RTBC. This needs to be committed.

Ace Cooper’s picture

It get closer the fields each other in the columns but never fixed it totally.
I've tried in Bartik and I think that is happening the same thing.
In the attached jpg files I am using the patch in #8

@Rafix: Of course, you have to apply some CSS to get it working! (screenshot 1, screenshot 2)

I forgot to mention *he said sarcastically*, that after my patch in #8 I also set the size of <td>'s with CSS.
While without #8 table cells of single line ignore the width setting and fill up the space of missing <td>'s.

Please, commit the patch already.
I have to apply this fix to my 4th project in a row.

remixed’s picture

The problem I have is the same, but only happens when less then 2 rows are used for a item.

The #8 fix doens't work for me, does anyone else know the problem?

Ace Cooper’s picture

@remixed:
Show me the HTML of your <table> and your CSS for <td> elements, not the rendered pages.

You clearly forgot to apply CSS, something like td { width: 25%; } (for fixed width table) or td { width: 250px; } (for fluid width table).
The patch does not fix CSS output for every custom theme, but it restores missing <td>s in table output of views.
It's not the fault of patch #8, but the archaic behaviour of <table>s, introduced back in 1997.
Read #32 carefully, look at screenshot 2 there.

Rafix’s picture

@Ace Cooper
Thank you man. That was the problem. Now it is fixed!

rrrob’s picture

Ace Cooper is correct. This patch *only* fixes the HTML output. Since it will output empty <td>s to fill the row, you must use CSS to give the <td> some width.

Bernsch’s picture

OK, i think we can commited to dev :-)

skwashd’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
875 bytes

The patch from #8 is no longer applying cleanly against 7.x-3.x-HEAD. Rerolled version attached.

RedEight’s picture

#38 correctly fills up the tr with empty tds. CSS is still needed to get the desired effect.
CSS that worked for a 4 column grid

.views-view-grid.cols-4 .row-1 > td {
    width: 25%;
}

Just adjust cols-4 and the width to match your specific case. Basically cols-n needs width 1/(n).
Recommend that #38 be committed if test passes.
#38: views-fill_up_single_row-1744478-38.patch queued for re-testing.

jseltzer’s picture

Patch in 38 works perfectly

Thanks!

MustangGB’s picture

Status: Needs review » Reviewed & tested by the community

This is still RTBC.

metakel’s picture

Patch in 38 works. After patching Views generates the correct number of "TD" tags even if the number of rows is fewer than the number of columns in the grid.

The latest dev version 7.x-3.7+21-dev and the stable version 7.x-3.7 both have this problem and both are not patched. Please proceed and commit it to them!

metakel’s picture

I found that in the newly released 7.x-3.7+22-dev (Jan 11, 2014), the problem is still there. I have to patch the file as in #38 again to make the grid works normally.

caktux’s picture

Assigned: Ace Cooper » Unassigned
Priority: Normal » Major
Issue summary: View changes

Get this in already! Wake up! Yes, I could turn off notifications. No, it's not the solution. Commit this now, it's been well over a year, reviewed and circlejerked around enough. Thank you.

pfrenssen’s picture

Priority: Major » Normal

Please do not mess with the priorities to try to promote patches. That doesn't help getting it in faster. The patch will be committed in time at the maintainers' discretion.

In the meanwhile if you are affected by this problem, you can apply the patch.

caktux’s picture

Priority: Normal » Major

I'm not promoting it by changing the priority, this is where the priority should have been all along. I've commented and patched it long ago, I'm complaining because new users still hit those problems which are major because it is so trivial to have the right number of columns on single rows.

awasson’s picture

I'm not going to comment either way about the severity of the issue but I agree with caktux. Let's get the patch at #38 rolled into Views. If there's a reason why the patch can't be applied, let's hear why. It's hard to be motivated to fix problems like this (however simple) when after we've done the work to patch and test, there's no activity.

couturier’s picture

It's true that hours of work are wasted on many Drupal modules because patches aren't committed within a reasonable time frame. This discourages people from contributing. Sometimes it is easier to get a patch committed if it is fixed in D8 first and then offered for D7. However, the grid table template will be replaced with one using divs for D8, so it is a completely different format. See [Change notice] Replace the views grid table template with one using divs

I agree this patch should be committed, but if maintainers say they do not have time, then D8 is coming soon and the problem there should be resolved.

thomas1977’s picture

Been working for hours in order to find out why it wasn't possible to show correct number of td's/columns when output results are less than the grid setting. Been pulling my hair out. FINALLY found this thread - so, thanks!

However: any timeline from maintainers for when the patch get's integrated in a release/dev version? ...so we don't have to do manual patching (something that I haven't done before)...

Best

Edit: don't want to sound impatient, really, but this IS truly annoying, not least considering that Views is otherwise such an amazing (!!) peace of software.

mengi’s picture

D8 is coming soon and will be resolve the issue is not a good solution...

I've been using this module (https://drupal.org/project/views_responsive_grid) and it has worked well for me. Instead of using tables, it uses divs. Hope that helps someone out.

majorrobot’s picture

Works well for us, too. It's a very small, logical change — would love to see this in the next release!

thomas1977’s picture

@ #50 - Thanks, will try this as soon as possible!

david_garcia’s picture

+1 please commit.

nowidid’s picture

+1 please commit #38. Thanks!

hoangdk80’s picture

Worked for me, commit +1

3CWebDev’s picture

+1 for #38 Patch. Is this going into core?

Daniel Kulbe’s picture

+1 for patch #38

PhilY’s picture

patch #38 works fine with Views 7.x-3.8

khiminrm’s picture

#38 works for me too. Views 7.x-3.8

alh’s picture

Patch #38 works for me with 7.x-3.8. I'm actually pretty shocked that this hasn't been committed. Seriously this is an ancient issue. And a simple fix. I work in both Wordpress and Drupal and I am beginning to think Wordpress is winning the hearts and minds of developers. No they are not perfect but there seem to be many fewer issues with Wordpress. Perhaps the Drupal community needs to focus on maintaining the current, mainstream releases as opposed to the new and shiny updates in Drupal 8 and 9.

egor.malygin’s picture

Guys, why is this not in the release yet?

liezie_D’s picture

+1 for patch #38 on Views 7.x-3.8.

please commit

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 38: views-fill_up_single_row-1744478-38.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 38: views-fill_up_single_row-1744478-38.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 38: views-fill_up_single_row-1744478-38.patch, failed testing.

Caligan’s picture

#38 worked for me. Patch applies cleanly to latest.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 38: views-fill_up_single_row-1744478-38.patch, failed testing.

Caligan’s picture

I don't understand what's going on with this. The patch works fine, but the error output where it's breaking down appears to imply that something is wrong with the tests. Anybody cleverer than me know what this output means?

Output: [ERROR: Unknown argument 'sites/default/modules/views/tests/node/views_node_revision_relations.test,sites/default/modules/views/tests/comment/views_handler_filter_comment_user_uid.test, [...] ,sites/default/modules/views/tests/views_query.test,sites/default/modules/views/tests/views_argument_validator.test,sites/default/modules/views/tests/templates/views-view--frontpage.tpl.php'.].

Status: Needs work » Needs review
petednz’s picture

so it is failing even to fail now?

Ace Cooper’s picture

Lots of time has passed and yet this issue is still around.
It's like developers don't even pay attention to the threads any more.

Just updated an old website to Views 7.x-3.x-dev from a two-year-old Views 7.x-3.8-ish installation. Got the same problem. And my patch from #8 still works fine.

thomas1977’s picture

@ Ace Cooper

I've been hesitating to apply your patch hoping for at "proper release". But simply couldn't wait anymore - and guess what: your patch works perfectly so far.

Thanks!

Best,
Thomas

schiavone’s picture

Version: 7.x-3.x-dev » 7.x-3.14

This is an issue for views 7.x-3.14 in either vertical or horizontal alignment.

MustangGB’s picture

Version: 7.x-3.14 » 7.x-3.x-dev

Sure, but the patch has to chase dev, that's just how the issue queue works.

schiavone’s picture

Re-rolled patch for 7.x-3.x-dev

schiavone’s picture

Is that a pass I see? Perhaps we can get this into dev now?

skwashd’s picture

Patch #79 is the same as my patch (#38) except that the bot wants to test it. I can't RTBC this as it is my essentially my own patch.

MustangGB’s picture

schiavone’s picture

@skwashd Yep, looks like the testbot was looking for standard naming conventions for the patch. My participation was not in creation, only editorial ;-)

TenaMurphy’s picture

Having the same issue as OP and #8 (= #79 patch) works for me. Thanks Ace Cooper!
I'm using views 7.x-3.14 and Omega 3.x subtheme which already set the necessary CSS. One line change from #8 was all I needed.

RedEight’s picture

Patch #79 worked fantastically! Thanks skwashd and schiavone.

petednz’s picture

Status: Needs review » Reviewed & tested by the community

Marking as RTBC since I am seeing 2 'works for me'. hope that is okay.

DamienMcKenna’s picture

DamienMcKenna’s picture

Issue tags: +Needs change record

I think this might need a change notice, as it could affect the output for some sites.

DamienMcKenna’s picture

Taking this off the plan for the next release, will consider it later.

MustangGB’s picture

Is this later enough yet?

  • DamienMcKenna committed 5c262a6 on 7.x-3.x
    Issue #1744478 by schiavone, skwashd: Grid format disregards "number of...
DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks all.

Could someone please work on a change notice?

Status: Fixed » Closed (fixed)

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