Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在这种情况下,当有很多列的ScrollX=TRUE时,焦点将丢失 TL;博士_R_Shiny_Datatables_Dt - Fatal编程技术网

在这种情况下,当有很多列的ScrollX=TRUE时,焦点将丢失 TL;博士

在这种情况下,当有很多列的ScrollX=TRUE时,焦点将丢失 TL;博士,r,shiny,datatables,dt,R,Shiny,Datatables,Dt,scrollX=TRUE似乎有错误,但是overflow-x:auto在纯css中工作,但它不是动态的(并且没有解决方案) 编辑 2020年3月4日:为.dataTables\u length.dataTables\u filter.dataTables\u info.dataTables\u paginate添加了css 这是一个reprex,其中列的焦点丢失,滚动条返回左侧 运行应用程序 到右边最后一个柱子上去 将指针放在choosen列的筛选器中进行搜索 =>DT的卷轴向左移动,右侧聚焦

scrollX=TRUE
似乎有错误,但是
overflow-x:auto
在纯css中工作,但它不是动态的(并且没有解决方案)

编辑
2020年3月4日:为.dataTables\u length.dataTables\u filter.dataTables\u info.dataTables\u paginate添加了css

这是一个reprex,其中列的焦点丢失,滚动条返回左侧
  • 运行应用程序
  • 到右边最后一个柱子上去
  • 将指针放在choosen列的筛选器中进行搜索
  • =>DT的卷轴向左移动,右侧聚焦的列消失

2020年2月10日在github上创建的问题:为.dataTables_length.dataTables_filter.dataTables_info.dataTables_paginate添加了css。2020年2月10日在github上创建的问题:为.dataTables_length.dataTables_filter.dataTables_info.dataTables_paginate添加了css
library(shiny)
library(DT)
app<-
  shinyApp(
    ui = basicPage(
      
      fluidPage(
        h3("Home"),
        fluidRow(
          column (12,
                  div(DT::dataTableOutput('outblabla'),
                      style = "font-size:80%;white-space: nowrap;width:1500px")
          )
        )
      )
      
      
    ),
    
    server = function(input, output) {
      
      blabla <-  reactive({
        test<-data.frame(
          matrix (rep(c(c(999.2,2), 1200), 4000), nrow = 40, ncol = 30)
        )
        colnames(test) <-  paste("aaaa_bbbb_ccccc_ddddd_eeee_fffff", 1:30)
        
        return( test
        )
        
      })
      
      output$outblabla<- DT::renderDataTable(
        DT::datatable(blabla(),
                      style = "bootstrap",   class = "compact", filter='top',
                      selection = c("single"),
                      options = list(
                        bSortClasses = TRUE,iDisplayLength = 10,   width = "100%",
                        scrollX=TRUE,
                        autoWidth = TRUE
                      )
        )
      )
    }
  )
shiny::runApp(app)

library(shiny)
library(DT)
app<-
  shinyApp(
    ui = basicPage(
      
      fluidPage(
        tags$head(
          # 1) too large, it take the # of item and pages Previous/ Next 
          #    but it works with all type of options of DT (with or without # of item by page, smart search, ..)
          tags$style(type = "text/css", HTML(paste0(".datatables                       {position: relative; } "))),
          tags$style(type = "text/css", HTML(paste0(".datatables  [class^='col-']      {position: inherit;} "))),
          tags$style(type = "text/css", HTML(paste0("
                                                   .datatables .dataTables_wrapper   {
                                                         overflow-x: auto;  
                                                         overflow-y: hidden; 
                                                         padding-top: 35px; 
                                                         padding-bottom: 35px;
                                                   }"))),
          tags$style(type = "text/css", HTML(paste0(".datatables .dataTables_length    {position: absolute; margin-top: -35px; left:  0px;}"))),
          tags$style(type = "text/css", HTML(paste0(".datatables .dataTables_filter    {position: absolute; margin-top: -35px; right: 0px;}"))),
          tags$style(type = "text/css", HTML(paste0(".datatables .dataTables_info      {position: absolute; left:  0px;}"))),
          tags$style(type = "text/css", HTML(paste0(".datatables .dataTables_paginate  {position: absolute; right: 0px;}"))),
               tags$style(type = "text/css", HTML(paste0("
                                                   .datatables .dataTables_wrapper .dt-buttons  {
                                                         left: 150px;
                                                         position: absolute;
                                                         top: 0;
                                                   }"))),    
          # OR
          # 2) It take only the table but it's not dynamic for all type of options of DT
          #tags$style(type = "text/css", HTML(paste0(".datatables .dataTables_wrapper .row:nth-child(2) > div:nth-child(1) {overflow-x: auto;}")))
        ),
        h3("Home"),
        fluidRow(
          column (12,
                  div(DT::dataTableOutput('outblabla'),
                      style = "font-size:80%;white-space: nowrap;width:100%;")
          )
        )
      )
      
      
    ),
    
    server = function(input, output) {
      
      blabla <-  reactive({
        test<-data.frame(
          matrix (rep(c(c(999.2,2), 1200), 4000), nrow = 40, ncol = 30)
        )
        colnames(test) <-  paste("aaaa_bbbb_ccccc_ddddd_eeee_fffff", 1:30)
        
        return( test
        )
        
      })
      
      output$outblabla<- DT::renderDataTable(
        DT::datatable(blabla(),
                      style = "bootstrap",   class = "compact", filter='top',
                      selection = c("single"),
                      options = list(
                        bSortClasses = TRUE,iDisplayLength = 10,   width = "100%",
                        scrollX=FALSE,
                        autoWidth = TRUE
                      )
        )
      )
    }
  )
#shiny::runApp(app)

library(shiny)
library(DT)
app<-
  shinyApp(
    ui = basicPage(
      
      fluidPage(
        tags$head(
          HTML(# I want to get event when DT Shiny is drawn, but it's doesn't work for load event
               "<script>
                $(document).on('focusin', '.datatables', function(event) {
                   $(this).find('table.dataTable').closest('div').addClass('div_containing_table');
                }); 
                </script>
               "
          ),
          tags$style(type = "text/css", HTML(paste0(".div_containing_table {overflow-x: auto;}")))
        ),
        h3("Home"),
        fluidRow(
          column (12,
                  p("You have to click on the table to simulate the end of loading of DT, to get scrollx"),
                  div(DT::dataTableOutput('outblabla'),
                      style = "font-size:80%;white-space: nowrap;width:1500px")
          )
        )
      )
      
      
    ),
    
    server = function(input, output) {
      
      blabla <-  reactive({
        test<-data.frame(
          matrix (rep(c(c(999.2,2), 1200), 4000), nrow = 40, ncol = 30)
        )
        colnames(test) <-  paste("aaaa_bbbb_ccccc_ddddd_eeee_fffff", 1:30)
        
        return( test
        )
        
      })
      
      output$outblabla<- DT::renderDataTable(
        DT::datatable(blabla(),
                      style = "bootstrap",   class = "compact", filter='top',
                      selection = c("single"),
                      options = list(
                        bSortClasses = TRUE,iDisplayLength = 10,   width = "100%",
                        scrollX=FALSE,
                        autoWidth = TRUE
                      )
        )
      )
    }
  )
#shiny::runApp(app)