Responsive tables in CMSB

13 posts by 3 authors in: Forums > CMS Builder
Last Post: July 22, 2023   (RSS)

By andreasml - July 16, 2023 - edited: July 17, 2023

Hi

I wonder whether it is possible to transform the sections' tables of CMSB in responsive tables (such as those found in https://elvery.net/demo/responsive-tables/) so that they will be seen better on a mobile phone screen?

Should I make changes in css color/theme files (/logbook/3rdParty/clipone/css/)?

Regards, 

Andreas Lazaris

By Dave - July 17, 2023

Hi Andreas, 

It would certainly be possible to do that with some custom javascript and CSS.  The issue would be how to specify which fields to omit unless you were going to hard code that.  If you add "hidden-xs" to the columns you want hidden they should disappear when the page width is less than 768px.

Dave Edis - Senior Developer
interactivetools.com

By andreasml - July 17, 2023 - edited: July 17, 2023

Hi Dave

Thanks for the reply. Again, I have not understood how I can do this for the table as seen on the first screen of every CMSB section.

I have left an example with a screenshot to understand what I am talking about. Suppose you want to omit the field in the red circle. How can it be done? Is there a specific file where I need to make these changes? 

Regards, 

Andreas

Attachments:

CMSB omit column.png 207K

By Djulia - July 17, 2023 - edited: July 18, 2023

Hi Andreas,

Can you try adding the following lines to your custom.css file?

@media only screen and (max-width: 800px) {
  [data-table="your_table"] tbody td:nth-child(7),
  [data-table="your_table"] thead th:nth-child(7) { display: none; }
}

@media only screen and (max-width: 640px) {
  [data-table="your_table"] tbody td:nth-child(5),
  [data-table="your_table"] thead th:nth-child(5),
  [data-table="your_table"] tbody td:nth-child(6),
  [data-table="your_table"] thead th:nth-child(6) { display: none; }
}

your_table = table name, (7) = column number

Thanks,
Djulia

By andreasml - July 18, 2023

Hi Djulia,

Thank you for your answer. I added your code to the Color / Theme CSS file, but unfortunately, I do not see any difference (I assume it is because of my fault and not your code). 

Here are a few questions to help me get some idea of what your code does: 

  1. What is the objective of the code?
  2. At your table, I assume I have to put the name of the section's name. Should I use only the name or together with its prefix? And what if I want to use it in more than one section? Should I copy the same code with a different table's name for each section?

What I would like to achieve is to make the section tables more user-friendly in a mobile screen environment, without the need to pinch out or scrolling horizontally to see all the details, etc. 

Thanks anyway for your time, 

Best regards, 

Andreas

By Djulia - July 18, 2023 - edited: July 18, 2023

Hi Andreas,

You need to add the code in your custom.css file in the CMSB installation folder (not in the Color/Theme CSS file).
You can find information in the custom.css.readme file.

>> What is the objective of the code?
The code will hide the columns on smaller screen sizes. The first example in your link (The Unseen Column).

The approach uses "Media queries" and "Attribute Selectors" to target the table :
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

>> At your table, I assume I have to put the name of the section's name.
Yes, the section name only without the prefix. And, yes, you have to add the code for each section you want to be adapted.

I hope this can help you.

Thanks,
Djulia

By andreasml - July 19, 2023 - edited: July 19, 2023

Hi Djulia

Great!! It does work!!! Thank you so much!!! 

Some more questions:

  1. Can you also provide me the code for the third example on my link ("No More Tables")?
  2. How can I change the action links (view, modify, erase) from texts to buttons?
  3. Is it possible to apply the some responsive type of tables in the reports as well?

Kind regards, 

Andreas

By andreasml - July 20, 2023 - edited: July 20, 2023

Thank you, Djulia. It is a great help. 

By the way, can you check the code for the plugin, as it does not seem to respond?

<?php
/*
Plugin Name: Custom td attributes
Description: Custom td attributes...
Version: 1.00
Requires at least: 2.65
*/

//
addFilter('listRow_tdAttributes', '_customtdAttributes', null, 4);

//
function _customtdAttributes($tdAttributes, $tableName, $fieldname, $record) {

	//
	if (@$tableName == '[data-table]') {
		$fieldLabel = _getFieldLabel($fieldname);
		$tdAttributes = 'data-title="'.$fieldLabel.'"';
	}

	//
	return $tdAttributes; // for all other fields
}

Also, do you know if it Is possible to apply the same responsive type of tables in the reports as well?

Many thanks again, 

Andreas

By Djulia - July 20, 2023 - edited: July 20, 2023

Hi Andreas,

Can you replace "[data-table]" with your table name (without the prefix)?

>>Also, do you know if it Is possible to apply the same responsive type of tables in the reports as well?
Yes, you will find the table line 196 in the plugin.

Thanks,
Djulia