Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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
Css 在行选择中更改R中数据表的bg颜色_Css_R_Shiny_Dt - Fatal编程技术网

Css 在行选择中更改R中数据表的bg颜色

Css 在行选择中更改R中数据表的bg颜色,css,r,shiny,dt,Css,R,Shiny,Dt,我正在尝试在R Shining应用程序中更改选择时数据表的背景颜色。已经为相同的CSS编写了CSS代码,但无法覆盖现有的CSS。任何解决方法都可以实现它 以下是我的代码: 用户界面 服务器 shinyServer(功能(输入、输出){ 输出$DataTable以下是更新的代码: 用户界面 服务器 shinyServer(功能(输入、输出){ 输出$DataTable@MLavoie谢谢。它有效。发布更新的代码。注意,您还可以有一个“活动”与“选定”的类。 library(DT) library(

我正在尝试在R Shining应用程序中更改选择时数据表的背景颜色。已经为相同的CSS编写了CSS代码,但无法覆盖现有的CSS。任何解决方法都可以实现它

以下是我的代码:

用户界面 服务器
shinyServer(功能(输入、输出){

输出$DataTable以下是更新的代码:

用户界面 服务器
shinyServer(功能(输入、输出){

输出$DataTable@MLavoie谢谢。它有效。发布更新的代码。注意,您还可以有一个“活动”与“选定”的类。
library(DT)
library(shiny)
library(shinydashboard)
library(shinyjs)

shinyUI(
dashboardPage (
dashboardHeader(title="Report"),
dashboardSidebar(sidebarMenu(menuItem("Table",tabName="Table"))),
dashboardBody(
tags$head(tags$style(HTML("

#DataTable tr.selected {background-color:cyan !important;}

table.dataTable.hover tbody tr:hover, table.dataTable.display tbody tr:hover    {
                          background-color: rgb(143,209,63) !important;
}



.odd {
background-color : rgb(173,219,241) !important;
}

.even {
background-color : rgb(232,245,251) !important;
}

"))),
useShinyjs() ,
            tabItems(
            tabItem(tabName = "Table",
                    DT::dataTableOutput("DataTable")    
                    )
))
))
shinyServer(function(input, output) {

output$DataTable <- DT::renderDataTable({
   datatable(iris,rownames=FALSE,selection = 'single',options = list(
   searching = FALSE,ordering=FALSE,
   dom = 'Bfrtip',
   buttons = c('copy','excel', 'pdf', 'print', 'colvis'),
   columnDefs = list(list(visible=FALSE, targets=c(2))),
   rowCallback = JS(
     "function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {",
     "var full_text = aData[2]",
     # Tooltip for the rows
     "$('td:eq(1)', nRow).attr('title', full_text);",
     # Showing a hand as a cursor
     "$('td:eq(1)', nRow).css('cursor','pointer');",
     "$('td:eq(1)', nRow).css('font-weight','bold');",
     "}")
     )
     )
     })
shinyUI(
dashboardPage (
dashboardHeader(title="Report"),
dashboardSidebar(sidebarMenu(menuItem("Table",tabName="Table"))),
dashboardBody(

tags$style(HTML("
table.dataTable tr.selected td,
                table.dataTable td.selected {
                background-color: rgb(143,209,63) !important;
                }
                ")),


tags$head(tags$style(HTML("

table.dataTable.hover tbody tr:hover, table.dataTable.display tbody tr:hover {
                          background-color: rgb(143,209,63) !important;
}    

.odd {
background-color : rgb(173,219,241) !important;
}

.even {
background-color : rgb(232,245,251) !important;
}

"))),
useShinyjs() ,
            tabItems(
            tabItem(tabName = "Table",
                    DT::dataTableOutput("DataTable")    
                    )
))
))
shinyServer(function(input, output) {

output$DataTable <- DT::renderDataTable({
datatable(iris,rownames=FALSE,selection = 'single',options = list(
searching = FALSE,ordering=FALSE,
dom = 'Bfrtip',
buttons = c('copy','excel', 'pdf', 'print', 'colvis'),
columnDefs = list(list(visible=FALSE, targets=c(2))),
rowCallback = JS(
 "function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {",
 "var full_text = aData[2]",
 # Tooltip for the rows
 "$('td:eq(1)', nRow).attr('title', full_text);",
 # Showing a hand as a cursor
 "$('td:eq(1)', nRow).css('cursor','pointer');",
 "$('td:eq(1)', nRow).css('font-weight','bold');",
 "}")
 )
 )
 })