Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Chris75forumname opened this issue Aug 3, 2023 · 3 comments

Comments

@Chris75forumname
Copy link

Chris75forumname commented Aug 3, 2023

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!

@splitbrain
Copy link
Member

AggregationTable::renderColumnHeaders() would be the place

// output XHTML header
$this->renderer->doc .= "<th $width $data>";
$this->renderer->doc .= '<a href="' . $link . '" class="' . $sortclass . '" ' .
'title="' . $this->helper->getLang('sort') . '">' . hsc($header) . '</a>';
$this->renderer->doc .= '</th>';

@Chris75forumname
Copy link
Author

Chris75forumname commented Jan 18, 2024

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
Copy link
Author

Chris75forumname commented Jun 12, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants