2016-06-21 19 views
2

私はより大きな光沢のあるインターフェイスをプログラミングしています.ui.r mainPanelにはtabPanelを含むtabsetPanelが含まれており、さまざまな種類のテーブルとプロット出力があります。スクロールしなければならないページが、例えば、(再)プロット出力、テーブルエントリなどを選択すると、そのスクロール位置でジャンプする傾向があることを除いて、それは素晴らしいように見える。ジャンプは時々ページの始めに、時には他のところに行く。 FirefoxとChromeの両方で発生します。したがって、そのようなジャンプを防止または抑制する方法はありますか?ご助力ありがとうございます。以下はスクロール後に光沢のあるページジャンプ

選択はページの一番下にあるテーブル行に行われた後のUIは、ページの一番上にジャンプする、最小限の例です。

library(shiny) 
library(DT) 
data=data.frame(x=1:10,y=2:11) 

ui=shinyUI(
    fluidPage(
    plotOutput("plot1"), 
    plotOutput("plot2"), 
    DT::dataTableOutput("tt") 
) 
) 

server=shinyServer(function(input, output) { 
    dd=reactiveValues(d=data) 
    output$plot1 <- renderPlot({plot(0,1)}) 
    output$plot2 <- renderPlot({plot(0,1)}) 
    output$tt=DT::renderDataTable(
    datatable(
     dd$d,selection =c('single') 
    ) 
) 
    observeEvent(input$tt_rows_selected,{ 
    dd$d[input$tt_rows_selected,1]<-log(dd$d[input$tt_rows_selected,1]) 
    }) 
}) 

shinyApp(ui,server) 
+0

サンプルコードを追加できますか?私は本当にあなたの質問を理解していないと[再現可能な例を提供する](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)非常に役立つだろう。 –

+1

確かに、上記を加えました。 – martin

答えて

0
library(shiny) 
library(DT) 
data=data.frame(x=1:10,y=2:11) 

ui=shinyUI(
    fluidPage(
    plotOutput("plot1"), 
    plotOutput("plot2"), 
    DT::dataTableOutput("tt") 
) 
) 

server=shinyServer(function(input, output) { 
    dd=reactiveValues(d=data) 
    output$plot1 <- renderPlot({plot(0,1)}) 
    output$plot2 <- renderPlot({plot(0,1)}) 
    output$tt=DT::renderDataTable(
    datatable(
     data,selection ='single' 
    ) 
) 
    observeEvent(input$tt_rows_selected,{ 
    dd$d[input$tt_rows_selected,1]<-log(dd$d[input$tt_rows_selected,1]) 
    }) 
}) 

shinyApp(ui,server) 

これは、のために働きます私。問題はselection = c('single')でした。それはselection = 'single'である必要があります。 DT::datatableのドキュメントでは、selectionに渡すことができる引数は、すべてのオプションが何であるかを示すためにc()に含まれています。

+1

ありがとうございます。しかし、それはうまくいかない。あなたの例では、renderDataTableのdd $ dをデータで置き換えました。これにより、_rows_selectedのobserveEventが廃止されます。応答性のある行の選択、ジャンプなし - どのような方法でも "single"を定義できます。あなたは、このポストからあなたの例を削除することを検討するかもしれない、多分? – martin

関連する問題