0

I am trying to replicate the answer provided at https://stackoverflow.com/a/45934505/7565465 for displaying complex headers in a data table using DT in R shiny. When I replicate the example, the table is formatted correctly, but my data is not displayed. If I remove "container = sketch" the data is displayed. What am I doing wrong with the call to "container?" Thank you.

sketch = htmltools::withTags(table(
              class = 'display',
              thead(
                tr(
                  th(rowspan = 2, 'ID'),
                  th(colspan = 2, 'Web Site'),
                  th(colspan = 4, 'Number of Edges'),
                  th(rowspan = 8, 'Position')
                ),
                tr(
                  th('URL'), th("Root URL"), th('Name'),
                  th('In'), th('Out'), th('Total')
                )
              )
            ))

   #dat is saved as a tibble
output$nodeList <- renderDT(dat %>% select( 
      id, url, rooturl, name, in_degree, out_degree, total_degree, betweeness), container = sketch)
jesse
  • 1
  • 3
  • Your second row in the header of `sketch` has only six cells. It has to have eight cells. – Stéphane Laurent May 07 '20 at 13:17
  • I appreciate your help @Stéphane Laurent, but I don't think that is it. The original example at the link I posted is formatted the same way. I did try implementing your suggestion putting all 8 variables in the second column. The data still did not populate the table and the first and last column headers were replicated. I suspect the problem has to do with calling 'container' with 'renderDT()', but I am unable to find guidance in the help files. – jesse May 08 '20 at 08:07
  • Ok. Does it work with `th(rowspan = 2, 'Position')`? Why do you want to span 8 rows? – Stéphane Laurent May 08 '20 at 11:38
  • Thank you @StéphaneLaurent; implementing `th(rowspan = 2, 'Position') ` did allow the data to populate the table, though my column headers were a little off but your solve allowed me to see how I could play around with the colspan and rowspan to achieve what I needed. I have posted the working code as a new answer. – jesse May 09 '20 at 14:41

0 Answers0