R闪亮的datatable过滤盒尺寸缩小查看文字 [英] R shiny datatable filter box size to narrow to see text

查看:209
本文介绍了R闪亮的datatable过滤盒尺寸缩小查看文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个R闪亮的仪表板,当我把数据放在一个表中使用DT包和renderdatatable()。在每列的顶部,我有过滤器,搜索框太窄,无法看到文本并选择一个选项。以下是图片:





有谁知道一种增加宽度的方法?



这是我在server.r中的datatable代码的代码:

  data<  -  rv $ data 
if(input $ sour!=All){
数据< - data [data [,1] == input $ sour,]
} else {data}
if(input $ sour1!=All){
data& -data [data [,2] == input $ sour1,]
} else {data}
if(input $ tran!=All){
data< -data [数据[,3] ==输入$ tran,]
} else {data}
},filter ='top'))

这里是ui.r中的代码:

  tabItem(tabName = ResultsTable,
fluidPage(
headerPanel(
h1(List,align =center,style =font-family:'Verdana'; font-weight:800; line ($,
#column(8,DT :: dataTableOutput(table,width =100%),o ffset = 2))),
##在UI中为selectInputs创建一个新行
fluidRow(

列(4,
selectInput(sour ,
Name,
c(All,
unique(as.character(df [,1]))))
),
列4,
selectInput(sour1,
Number,
c(All,
unique(as.character(df [,2]))))
),
列(4,
selectInput(tran,
代码:,
c(全部,
unique(as.character (df [,3])))))),
#Cr选择表的新行。
fluidRow(column(11,DT :: dataTableOutput(table,width =95%)))))

我尝试过这个,但没有起作用:

 输出$ table < -  DT :: renderDataTable(DT :: datatable({
data < - rv $ data
if(input $ sour!=All){
data< - data [data [ 1] == input $ sour,]
} else {data}
if(input $ sour1!=All){
data< -data [data [,2] = = input $ sour1,]
} else {data}
if(input $ tran!=All){
data< -data [data [,3] == input $ tran,]
} else {data}
},filter ='top',options = list(
autoWidth = TRUE,
columnDefs = list(list(width ='200px ',targets =_all))
))


解决方案

此处回答了类似的问题。



另外,按照使用范围滑块来过滤范围内的行,请考虑使用<$ c $将日期列表列转换为日期格式c> as.Date()。


I'm building an R shiny dashboard and when I put my data in a table using the DT package and renderdatatable(). At the top of each column, I have filters, the search box is too narrow to see the text and select an option. Here's an image:

Does anyone know of a way to increase the width?

Here's my code for the datatable code in the server.r:

  output$table <- DT::renderDataTable(DT::datatable({    
    data <- rv$data
    if (input$sour != "All") {
      data <- data[data[,1] == input$sour,]
    }else{data}
    if (input$sour1 != "All") {
      data <-data[data[,2] == input$sour1,]
    }else{data}
    if (input$tran != "All") {
      data <-data[data[,3] == input$tran,]
    }else{data}
  },filter='top'))

here's the code in the ui.r:

 tabItem(tabName = "ResultsTable",
              fluidPage(  
                headerPanel(
                  h1("List", align="center",  style = "font-family: 'Verdana';font-weight: 800; line-height: 1.1;   color: #151515;")),
                # fluidRow(
                #     column(8, DT::dataTableOutput("table",width = "100%"),offset = 2)))),
                #                 # Create a new Row in the UI for selectInputs
                fluidRow(

                  column(4,
                         selectInput("sour",
                                     "Name:",
                                     c("All",
                                       unique(as.character(df[,1]))))
                  ),
                  column(4,
                         selectInput("sour1",
                                     "Number:",
                                     c("All",
                                       unique(as.character(df[,2]))))
                  ),
                  column(4,
                         selectInput("tran",
                                     "Code:",
                                     c("All",
                                       unique(as.character(df[,3])))))),
                # Create a new row for the table.
                fluidRow(column(11, DT::dataTableOutput("table",width = "95%")))))

I tried this, but it did not work:

 output$table <- DT::renderDataTable(DT::datatable({    
    data <- rv$data
    if (input$sour != "All") {
      data <- data[data[,1] == input$sour,]
    }else{data}
    if (input$sour1 != "All") {
      data <-data[data[,2] == input$sour1,]
    }else{data}
    if (input$tran != "All") {
      data <-data[data[,3] == input$tran,]
    }else{data}
  },filter='top',options = list(
    autoWidth = TRUE,
    columnDefs = list(list(width = '200px', targets = "_all"))
  )))

解决方案

A similar question was answered here.

Also, in order to use range sliders to filter rows within ranges, consider converting the "Date List" column to the date format using as.Date().

这篇关于R闪亮的datatable过滤盒尺寸缩小查看文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆