How do I suppress row names when using DT::renderDataTable in R shiny?

后端 未结 1 973
攒了一身酷
攒了一身酷 2020-12-08 18:46

As per the explanation in section 2.3 here, I can remove rownames for a datatable by setting rownames = FALSE

相关标签:
1条回答
  • 2020-12-08 19:06

    Please be very careful to read the help pages of functions to know which argument belongs to which function. In your case, the rownames argument belongs to the datatable() function, but you actually put it inside the options argument, and that is certainly wrong. DT::renderDataTable() accepts either a data object or a table widget as its first argument (again, please read its help page), so either of the following expressions should work:

    DT::renderDataTable(datatable(
        subsetTable(), filter = 'top', server = FALSE, 
        options = list(pageLength = 5, autoWidth = TRUE),
        rownames= FALSE
    ))
    
    DT::renderDataTable(
        subsetTable(), filter = 'top', server = FALSE, 
        options = list(pageLength = 5, autoWidth = TRUE),
        rownames= FALSE
    )
    

    In the latter case, rownames = FALSE is passed to datatable() internally, per documentation of the ... argument of the help page.

    0 讨论(0)
提交回复
热议问题