dokuwiki-plugin-struct icon indicating copy to clipboard operation
dokuwiki-plugin-struct copied to clipboard

Feature request: add class to table header according to field type

Open Chris75forumname opened this issue 2 years ago • 3 comments

I would like to add classes to table headers

according to field type, e.g. dropdown, so I can reference columns when adding features to struct tables. Could anyone please point me to the location in the code where those classes could be added? Thanks!

Chris75forumname avatar Aug 03 '23 10:08 Chris75forumname

AggregationTable::renderColumnHeaders() would be the place

https://github.com/cosmocode/dokuwiki-plugin-struct/blob/7fe2cdf28c472c686961bf42f0123eb33d2f3e60/meta/AggregationTable.php#L231-L235

splitbrain avatar Nov 01 '23 09:11 splitbrain

Thanks Andi for the pointer!

I did this (just for the records):

        // output XHTML header
        $this->renderer->doc .= '<th ';
        if ( is_a($column->getType(), '\dokuwiki\plugin\struct\types\User') ) { 
            $this->renderer->doc .= 'class="struct_user" ';
        }
        $this->renderer->doc .= "$width $data>";

I picked this up again and it workes for me like this, because I need this for struct type user, right now.

However, I would really find this useful for all headers (and all types). But, I don't know, how to do it. 😄

Cheers!

Chris75forumname avatar Jan 18 '24 12:01 Chris75forumname

And I replaced the line 367 here https://codesearch.dokuwiki.org/xref/plugin/struct/meta/AggregationTable.php#367 by the following three lines:

$fieldinfo = 'data-field="' . $this->columns[$colnum]->getFullQualifiedLabel() . '"';
$colclass = 'class="col' . $colnum . '"';
$this->renderer->doc .= "<td $colclass $fieldinfo>";

This puts the schema.Title info into each table data cell td. Now, I can go in CSS, like this:

[data-field="schema.Title"] { display: none; }

... which hides the whole column. Any other CSS rules per column are possible, now.

See here: https://forum.dokuwiki.org/d/22299-feld-vorbelegen-im-seriellen-editor

Chris75forumname avatar Jun 12 '24 12:06 Chris75forumname