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.
Responsive tables just got committed. Each $header can choose to be Essential (the default - needs no special class), RESPONSIVE_PRIORITY_MEDIUM, or RESPONSIVE_PRIORITY_LOW. For an example, this is from admin/content (node.admin.inc)
// Build the sortable table header.
$header = array(
'title' => array(
'data' => t('Title'),
'field' => 'n.title',
),
'type' => array(
'data' => t('Content type'),
'field' => 'n.type',
'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
),
'author' => array(
'data' => t('Author'),
'class' => array(RESPONSIVE_PRIORITY_LOW),
),
'status' => array(
'data' => t('Status'),
'field' => 'n.status',
),
'changed' => array(
'data' => t('Updated'),
'field' => 'n.changed',
'sort' => 'desc',
'class' => array(RESPONSIVE_PRIORITY_LOW)
,)
);
Comment | File | Size | Author |
---|---|---|---|
#10 | views-1796230-10.patch | 5.24 KB | dawehner |
#8 | responsive2.png | 19.06 KB | dawehner |
#2 | responsive1.png | 10.67 KB | dawehner |
#2 | views-1796230-2.patch | 3.25 KB | dawehner |
#2 | views.view_.blub_.yml_.txt | 2.54 KB | dawehner |
Comments
Comment #1
sebas5384 CreditAttribution: sebas5384 commentedNice idea!
I think it doesn't need a constant for that, a simple class would be just fine, like ajax from core("use-ajax") and ctools with modals for example.
Cheers!,
Sebas.
Comment #2
dawehnerSome has to explain me this feature ...
I created a table with nid, title, type and set medium to nid, and low to type.
Once i shrink my browser window i only see title and type, though i would expect nid and title,
see screenshot.
Additional to be able to expose this to users, i would suggest more something like
"responsove priority":
none => high
medium => medium
low => low
Comment #3
dawehnerAdd missing tag.
Comment #4
hass CreditAttribution: hass commentedWhat we need here is a "class per column" as I know. Views currently allows only a "class per row".
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedTake a look at the HTML Source and see what classes are on the header cells and row cells. If they don't match what you expect, that would explain the result ... theme_table() copies classes from header to cells so it would likely be harmless if Views adds the responsive classes to the rows as well.
Comment #6
hass CreditAttribution: hass commentedIs there any chance to make this a unified "class per column" feature? I have real theming need to add classes to colums in D7, too.
Comment #7
tim.plunkett@hass that is clearly a separate feature request
Comment #8
dawehner@hass ... Forgive me to not answer support questions in d8 issues. This is possible all the time,
but i would like to have an addition setting, as many people might not know the class names you need for responsive tables.
The actual rendered css classes are looking fine, at least for me, see screenshot.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedYou have a leading space in the class name. Doubt that matters but who knows. Next I would look at the media queries in the CSS and see why they are not matching against your classes. make sure to flush caches in case you have an old aggregated css in play.
Comment #10
dawehnerI'm confused by bartik/style.css, this explains why it works for me in the admin
interface but not on the "frontend".
compared to the css of seven/stark:
Regarding the space in front, this will be automatically fixed in
another issue, which converts the classes to Attributes objects.
Beside the css classes, i added the javascript for the responsive table js as well.
Comment #11
dawehnerThere is a core issue about this problem now: #1800304: The css for responsive tables on bartik contains old class names
Comment #12
dawehnerDue to the core commit this works fine now, let's get this is as noone seems to have an interest in reviewing.
I really really like this new feature in core!
Comment #13
aspilicious CreditAttribution: aspilicious commentedI'm interested! I like the patch!
Comment #14
xjmWay cool. Thanks @moshe weitzman and @dawehner.
Comment #16
kaizerking CreditAttribution: kaizerking commentedI would like to test it if back ported to D7
Comment #17
tim.plunkettThis issue was only about supporting improvements made in core. Backporting it would mean Views would shoulder the entirety of that improvement, which I'm not sure is reasonable. Either way, please open a new feature request.
Comment #18
DamienMcKennaThere's always the work Dave Reid and others are putting into backporting the code for D7: http://drupal.org/project/responsive_tables