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

_state does not update when columns change visibility #256

Closed
MikeBadescu opened this issue Mar 24, 2016 · 4 comments
Closed

_state does not update when columns change visibility #256

MikeBadescu opened this issue Mar 24, 2016 · 4 comments
Labels
Milestone

Comments

@MikeBadescu
Copy link

Similar to #146 I am trying to save the state of column visibility. However, the _state variable does not update when columns are hidden or shown but it updates if search or filtering are used.

Related question: would it possible to return the column visibility when stateSave = FALSE?

library(shiny)
library(DT)

shinyApp(
    ui = fluidPage(
        DT::dataTableOutput('foo')
    ),

    server = function(input, output) {
        output$foo = DT::renderDataTable(
            iris, 
            selection = 'single', 
            extensions = 'Buttons',
            rownames = FALSE,
            options = list(
                dom = 'Bfrtip', 
                buttons = I('colvis'),
                stateSave = TRUE
            ))

        observe({
            fs <- input$foo_state
            if (is.null(fs)) {
                print(NULL)
            } else {
                cols <- fs$columns
                cv <- vapply(cols, FUN = function(x) x$visible, TRUE)
                print(cv)
            }
        })
    }
)
@yihui
Copy link
Member

yihui commented Mar 24, 2016

I'm not quite sure about that, since I have not really read the documentation of the colvis button yet. As long as there is a JS event triggered when clicking the buttons, I think it should be possible to update the state of column visibility.

@MikeBadescu
Copy link
Author

There is a button-action event, but maybe using column-visibility is better (I am not a JS expert).

@yihui yihui added the bug label Jul 29, 2016
@yihui yihui added this to the v0.2 milestone Jul 29, 2016
@yihui yihui closed this as completed in 1db7d84 Jul 29, 2016
@yihui
Copy link
Member

yihui commented Jul 29, 2016

Should be fixed now. Thanks for the report!

@MikeBadescu
Copy link
Author

Thank you for fixing this - now it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants