Concern: I am dealing with a HTML table that contains multiple columns, with the last column being "Stack Trace" which is often lengthy. The complete display of the stack trace leads to poor table formatting.
Goal: My aim is to showcase the "Stack Trace" as truncated text with a 'Show more/less' button. Upon clicking the 'Show more/less' button for any cell, it should reveal/hide the full "Stack Trace" specific to that cell.
Provided below is my csv file.
DATETIME,HOST,REQUEST,STACK_TRACE
5/13/2022 15:04:05,host1,POST,"java.lang.Exception: Stack trace at java.base/java.lang.Thread.dumpStack(Thread.java:1383) at com.ericgoebelbecker.stacktraces.StackTrace.d(StackTrace.java:23) at com.ericgoebelbecker.stacktraces.StackTrace.c(StackTrace.java:19) at com.ericgoebelbecker.stacktraces.StackTrace.b(StackTrace.java:15) at com.ericgoebelbecker.stacktraces.StackTrace.a(StackTrace.java:11) at com.ericgoebelbecker.stacktraces.StackTrace.main(StackTrace.java:7)"
5/13/2022 15:06:05,host2,POST,"Exception in thread ""main"" java.lang.RuntimeException: A test exception at com.stackify.stacktrace.StackTraceExample.methodB(StackTraceExample.java:13) at com.stackify.stacktrace.StackTraceExample.methodA(StackTraceExample.java:9) at com.stackify.stacktrace.StackTraceExample.main(StackTraceExample.java:5)"
5/13/2022 15:07:05,host5,GET,"java.lang.Throwable: A test exception at com.stackify.stacktrace.StackElementExample.methodD(StackElementExample.java:23) at com.stackify.stacktrace.StackElementExample.methodC(StackElementExample.java:15) at com.stackify.stacktrace.StackElementExampleTest.whenElementOneIsReadUsingThrowable_thenMethodCatchingThrowableIsObtained(StackElementExampleTest.java:34)"
CSS Attempted Solution: -
<head><style>
table{
width:100%;
table-layout: fixed;
overflow-wrap: break-word;
}
th:nth-child(4){ width:60%; }
td:nth-child(4){
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
</style></head>
Findings: The current setup displays a truncated version of the "Stack Trace" without providing a 'Show more/less' option.
https://i.sstatic.net/hZIew.jpg
I require a 'Show more/less' button/link that, when activated, will reveal/hide the complete "Stack Trace" for the respective row cell.