-1

I noticed by using FooTable display on one of my view on a Drupal 8 site, it is increasing the load time of the view by more than 2000 ms.

The main idea i am using Footable is because of the ability to hide fields within the table row and make them visible once you click on that table row (collapsable fields).

Can I build using only views such table with collapsable fields without having the Footable module installed ?

Any help suggestions just to make me start !

Below is an image of what i am trying to build using only views core module:

Collapsible Table

Note: The responsiveness of the table is not important in my case !

I want the table to always display 4 columns (one field in each column) and when the "See More" link is clicked, the other fields will show/hide inside a collapsible accordion.

  • Remember, the FooTable plugin permits wide tables to appear as common on large displays but on smaller screens, it can hide particular columns within increasing and collapsing rows. – Moshe Strugano Jun 15 at 11:27
  • Why? If FooTable improves your performance why would you drop it? Don't you think that Views itself wouldn't already have boosted performance drastically if it could? Plus, have you already looked how FooTable does it (as in read its code) and then tried to rebuild that with just Views itself? What help exactly are you looking for? – leymannx Jun 15 at 11:34
  • @leymannx i am sorry it was a mistake, i mean increasing instead of decreasing... question corrected... – user93906 Jun 15 at 11:50
0

A module that provides the "collapsible" functionality is Views Accordion so maybe you can try it and see if it performs better.

But it doesn't change the layout depending on the browser width.

The proper way of addressing this is with CSS. You can use CSS grid to make the fields appear as a table on wider widths, and stacked one below the other on narrow widths. You can even recreate the accordion look where some fields are hidden initially, you click on the visible ones to show all the rest. I expect this solution would score highest in performance, but I'm not aware of any contributed modules that provide it for D8, you can build it yourself in your subtheme.

For D7 there is Views CSS Tables.

The CSS route may not support some older browsers so it depends on your project's visitors stats if it's safe to go that way.

Edited: Yes, I think it can be done, although I've never tried it in Views like that, and it's definitely not trivial. The concepts you need to learn are about:

  • please check the update to my question, can the example image be don using CSS and only views core module ? can you reference know tutorial ? – user93906 Jun 15 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy