Outputting sortable tables from a Static Content Macro

Hi,

I develop a macro which outputs tables onto Confluence pages and I’d like to make the tables sortable like they are with tables manually inserted into Confluence pages.
I know this is achievable using Dynamic Content Macros and AUI or another framework but I don’t want to use a Dynamic Content Macro because those can only be loaded over GET requests which means I cannot get access to the macro body in the preview screen (as the history API returns a 404 because the page hasn’t been saved yet). Whereas Static Content Macros can access the body in preview mode because they can use POST as the renderingMethod and receive the entire body in preview mode regardless of how big it is.
Anyway, is there a way maybe be adding some classes to my table by which the Javascript already running in the Confluence page would detect my table and make it sortable, like manually inserted Confluence tables are?

thanks,

Matt

3 Likes

Hi @matthew.grover,

I’m not aware of how this might work. My only suggestion is to try to inspect a current page with a table and try to replicate all of the classes in your table creation to see if that works for you.

Also, another consideration is maybe to look into Forge as a way to generate your table. This works without an iFrame and might be able to get around the issue of not being able to get the content.

I have the same question. @matthew.grover did you find a solution to this? It looks like that the default macros render tables just fine, but any custom static macros still use the old table styles. Very annoying. - @rwhitbeck can you try to pull someone in to clarify if there is some way to make the custom macros work like the system default macros?

Here is an example:
Two macros with the same table as input:

Different results when page is viewed / rendered (styles are off, table is not sortable):

Thanks!

1 Like