Aligning table data with dataviewjs

I would like to right-justify numeric cells in a dataviewjs table. Does anyone know how to do this? In CSS it’s obvious, but I haven’t figured out how to use it with dataviewjs. Based on what I’ve read, adding this looks promising:

this.container.querySelectorAll(".markdown-preview table td").forEach(s => = "right");

and doesn’t throw an error. It doesn’t do anything though. Can someone point out the error of my ways?


Bump, ended up here after googling around for the same question :slight_smile:

Why can’t you use CSS to do it? It’s most likely a lot easier to specify your formatting through that instead of trying to manipulate the DOM from within your dataviewjs script.

What you could within your script, though, is to add the following:

dv.container.className += " uniqueIdForMe"

Which would add that class name to this particular table, allowing for easy targeting through CSS.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.