Add data-attributes to table cells in RTE
# help-with-umbraco
j
Hi all, To make tables more responsive I want to add some data-attributes to the cells, that are equal to the
th
in the table. This way, I can make cards instead of rows on mobile, using this data-attributes in css. (see [this example](https://codepen.io/AllThingsSmitty/pen/MyqmdM) ) Is there a way to intercept the rendering part of RTE and add my own logic to it, so I can add the data-attributes automatically? I don't want the content editor to have to worry about this, and make mistakes in the code.
j
But for that you need to know HTML code, right? I don't want to do that to the editors.
h
No, what I posted above was all done using the table plugin I didn't edit the html directly
j
ah, ok. I will have a look at it.
h
you may need to apply some config changes, what version of umbraco are you using?
j
v13 for this specific project
h
OK, in appsettings RichTextEditor section you need to add the following to CustonConfig section
Copy code
"CustomConfig": {
          "table_header_type": "sectionCells",
}
then when you set a row properties to header it will add the role="col" auttomatically
j
ah, ok. But the
scope="col"
is not exactly what I need. I want to add
data-label="<dynamic text>"
to the table cells. Where dynamic text is the value in the cells.
h
that wouldn't be possible without writing your own tinymce plugin
j
I was hoping there was some way in Umbraco to hook in to that 😇
But thanks for your help @huwred, much appreciated
s
You could probably do a custom property value converter, and modify the table using HtmlAgilityPack
But I guess editors will interpret a table as "grid based" text, and break the constraints from time to time (headings in cells, related content in different rows etc.)
j
Yeah, it's gonna be a tricky one. I think I'm gonna try it with a tinyMCE plugin, because I then can use it in any CMS that uses tinymce.
s
But then it's also on the editor to fill out, I guess?
15 Views