Skip Navigation

[Resolved] responsive Table

This thread is resolved. Here is a description of the problem and solution.

Problem:
The Table output format of Views is not responsive. How can responsive tables be made?

Solution:
An alternative would be to use a responsive Bootstrap grid in place of a table.

But the markup generated by the Loop Wizard for a Bootstrap grid is designed around the idea of one post per column, whereas a table is built upon one post per row (with the fields distributed across the columns).

To achieve something similar with Bootstrap requires manually editing the Loop Output, as described in the response below: https://toolset.com/forums/topic/responsive-table-2/#post-1238198

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.44 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 3 voices.

Last updated by loriD 5 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#1237222

Tell us what you are trying to do?
I am trying to replace a table I currently have with a responsive version of it.
Is there any documentation that you are following?
your documentation hasn't been helpful

Is there a similar example that we can see?
this is what I want
hidden link

What is the link to your site?

hidden link

I am hoping I can replicate the table I currently have as a responsive grid.

I would like to have headers on top of the columns as well as some content in the footer of the table.

I am getting the rest of the content to populate as I want but I can not isolate the headers the way I would like.
Thank you

#1237476

Hello,

Please elaborate the questions with more details.
I have tried both URLs you mentioned above:
hidden link
There is a HTML table in above URL.
hidden link
I don't see the HTML table in above URL, where and how can I see the table?

I assume you are going to format view's result as HTML table, I suggest you check this document:
https://toolset.com/documentation/user-guides/view-layouts-101/#table

Then use custom CSS codes to style the HTML table to what you want.

#1237722

You are not understanding me. (This is why I suggested Nigel help, but okay)

I am trying to make my site responsive. View tables are not responsive. I am recreating pretty much everything in views with bootstrap so they can be responsive.

hidden link - this is the original table - not responsive

hidden link - this is the table I currently have created with bootstrap grid. I want it to look like the original AND be responsive.

The documentation you provided isn't going to give me a responsive table nor a responsive grid.

#1238198

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lori

You correctly recognise that HTML tables are not responsive and need to replaced with an alternative such as a grid.

Let's compare the markup that the Loop Wizard generates when creating a table vs. creating a grid.

Table first (edited by me for the header and footer):

	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%">
      <thead>
        <tr>
          <th>Post link</th>
          <th>Post date</th>
          <th>Status</th>
          <th>Excerpt</th>
        </tr>
      </thead>
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				[wpv-post-body view_template="loop-item-in-table-of-tasks"]
			</tr>
		</wpv-loop>
		</tbody>
      <tfoot>
        <tr>
          <th colspan="4">Some text</th>
        </tr>
      </tfoot>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]

And here's what it looks like for a 4-col Bootstrap grid:

	[wpv-items-found]
	<!-- wpv-loop-start -->
	<div class="container wpv-loop js-wpv-loop">
	<wpv-loop wrap="4" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-responsive-table-of-tasks"]</div>
		[wpv-item index=2]
			<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-responsive-table-of-tasks"]</div>
		[wpv-item index=3]
			<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-responsive-table-of-tasks"]</div>
		[wpv-item index=4]
			<div class="col-sm-3">[wpv-post-body view_template="loop-item-in-responsive-table-of-tasks"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-3"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-3"></div>
		</div>
	</wpv-loop>
	</div>
	<!-- wpv-loop-end -->
	[/wpv-items-found]

In both cases the linked content template includes four fields (title, date, status taxonomy, and excerpt), but in the case of the table it importantly includes table markup too:

<td>[wpv-post-link]</td>
<td>[wpv-post-date]</td>
<td>[wpv-post-taxonomy type="status"]</td>
<td>[wpv-post-excerpt]</td>

What you can hopefully see is that the Loop section with a table inserts the same thing every time: a row and whatever is in the linked template (row cells). Fields from one post are spread across a table row, and each row is one post.

The Bootstrap grid is conceptually different. Each item in the grid is one post, and a row contains as many posts as our grid has columns.

To make a grid that is more like a table (one post per row) we need to re-jig the markup so that each row includes the contents of the linked template, and that template adds the divs which split the content into Bootstrap columns.

So the Loop Editor looks like this (including rows for a header and footer that you edit as required):

	[wpv-items-found]
	<!-- wpv-loop-start -->
	<div class="container wpv-loop js-wpv-loop">
      <div class="row">Some header stuff</div>
		<wpv-loop>
			<div class="row">
			[wpv-post-body view_template="loop-item-in-responsive-table-of-tasks"]
      		</div>
		</wpv-loop>
      <div class="row">Some footer stuff</div>
	</div>
	<!-- wpv-loop-end -->
	[/wpv-items-found]

And then the template includes the column divs (much like the table view template includes the td elements):

<div class="col-sm-3">[wpv-post-link]</div>
<div class="col-sm-3">[wpv-post-date]</div>
<div class="col-sm-3">[wpv-post-taxonomy type="status"]</div>
<div class="col-sm-3">[wpv-post-excerpt]</div>

You'll have some styling considerations such as adding borders etc., but that's functionally how you use a grid to create a responsive "table".

#1238873

Thank you so very much Nigel, I was able to get it to work.
I don't necessarily like how it works responsively but I don't think there is much that can be done about it.
thank you again. I appreciate your help.
Lori