Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiny: .selection=colDef(show=FALSE) not working with columnGroups #52

Closed
petbrueck opened this issue Jun 18, 2020 · 2 comments
Closed

Shiny: .selection=colDef(show=FALSE) not working with columnGroups #52

petbrueck opened this issue Jun 18, 2020 · 2 comments
Labels
bug

Comments

@petbrueck
Copy link

@petbrueck petbrueck commented Jun 18, 2020

Hi,
Thanks for this great package!
I stumbled over the following issue:

Hiding the selection column using ".selection=colDef(show=FALSE)" is not working if I also create columnGroups.

library(shiny)
library(reactable)

ui <- fluidPage(
  reactableOutput("withoutcolumnGroups", height="600px"),
  reactableOutput("withcolumnGroups", height="600px")
  )

server <- function(input, output) {
   output$withoutcolumnGroups <- renderReactable({ 
   reactable( iris ,
              onClick="select",
              selection="single",
              columns=list(
                .selection = colDef(show=FALSE)
              )
   )
 })

 output$withcolumnGroups <- renderReactable({ 
   reactable( iris ,
              onClick="select",
              selection="single",
              columns=list(
                .selection = colDef(show=FALSE)
              ),
            columnGroups = list(
              colGroup(name = "ColumnGroup Header", 
                       columns = c("Petal.Length", "Petal.Width") 
              )
            ) 
   )
 })
}

shinyApp(ui = ui, server = server)

Is there any way to avoid this? Thanks in advance!

@glin glin added the bug label Jun 22, 2020
@glin
Copy link
Owner

@glin glin commented Jun 22, 2020

Thanks for reporting this. This was a bug that should now be fixed in the development version (4abe2d0). The problem was that there was an extra, empty column being added when using row selection + column groups. That extra column was what .selection = colDef(show = FALSE) was being applied to here.

It's more visibly obvious with a bordered style:

library(reactable)

reactable(
  data.frame(x = c(1, 2, 3)),
  selection = "multiple",
  columnGroups = list(colGroup("group", "x")),
  bordered = TRUE
)

screenshot of table

@petbrueck
Copy link
Author

@petbrueck petbrueck commented Jun 22, 2020

Thanks a lot! I can confirm that this bug has been fixed.

@glin glin closed this Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.