Reputation: 572
I want to delete a textOutput on the mainPanel using shiny. When the app starts there should be the text e.g. "welcome...". By clicking the action Button a datatable is printed and the text should be deleted and not written underneath the table. I tried it with something like this (see below) but output$mytable2
can't be used as an indicator (
Error: Reading objects from shinyoutput object not allowed.
). I have not included the whole code because I think this might be very basic but I can´t find a solution. (I also tried "removeUI
" to remove textOutput()
from ui inside the observeEvent
function of the button but this deleted everything)
ui : [...]
mainPanel(
DT::dataTableOutput('mytable2'),
textOutput("welcome1")
server: [...]
output$mytable2 <- DT::renderDataTable({
(DT::datatable(datasetInput(),rownames=FALSE))
})
fg<-reactive({text1<-c("Welcome..","")
fg<-2
if (is.null(output$mytable2)){fg=1}
return(text1[fg])})
output$welcome1 <- renderText({ fg() })...
Any easy Ideas? Just how to manage this exemplatory? Many thanks!
Upvotes: 0
Views: 549
Reputation: 3760
What about this solution:
ui.R
uiOutput("text)
actionButton("button1", "Go")
server.R
output$text <- renderUI({if(input$button1 == 0){paste("Welcome...")} else{return()}})
When actionButton
is not pressed, it has a value of 0, after pressing it, value changes to 1.
Therefore i have used the if...else..
statement saying if button has value 0, then show the text "Welcome...", if it changes to 1, return nothing.
Upvotes: 2