2016-12-13 10 views
1

DTライブラリののrowCallbackに無効な値を渡したいと思います。下記の例をご覧ください。私は光沢のあるランタイムでflexdashboardでこれを使用しています。DTのjavascript部分に光沢のあるreactive()値を渡します

は静的な値、カットオフ= 4 .Workingと

--- 
title: "Untitled" 
output: 
    flexdashboard::flex_dashboard: 
    orientation: columns 
    vertical_layout: fill 
    horizontal_layout: fill 
runtime: shiny  
--- 

```{r setup, include=FALSE} 
library(flexdashboard) 
library(DT) 
library(shiny) 
library(shinyjs) 
``` 

Column 
----------------------------------------------------------------------- 

テーブルを設定します。反応値と

### Chart A 

```{r,eval=T} 
output$mtcarsTable1 <- renderDataTable({ 
     DT::datatable(datasets::mtcars, 
     options = list(pageLength = 5, 
         searching= FALSE, 
         lengthChange = FALSE, 
         ordering=FALSE, 
         rowCallback = JS(' 
      function(nRow, aData, iDisplayIndex, iDisplayIndexFull,cutoff=4) { 
             // Bold and green cells for conditions 
             if (parseFloat(aData[10]) >= cutoff) 
             $("td:eq(4)", nRow).css("font-weight", "bold"); 
             }'))) 
    }) 
dataTableOutput('mtcarsTable1') 

``` 

表、カットオフ= gearvalue()、動作していません。

### Conditional Bold 

```{r} 
fillCol(flex = c(1, 6), 
     radioButtons("gearvalue","Sensitivity to gear column", c("4" = "4", "3" = "3"), inline=T), 
    dataTableOutput('mtcarsTable2'), 
    width = "100%") 
``` 


```{r,eval=T} 
output$mtcarsTable2 <- renderDataTable({ 
     DT::datatable(datasets::mtcars, 
     options = list(pageLength = 5, 
         searching= FALSE, 
         lengthChange = FALSE, 
         ordering=FALSE, 
         rowCallback = JS(' 
      function(nRow, aData, iDisplayIndex, iDisplayIndexFull,cutoff=gearvalue()) { 
             // Bold and green cells for conditions 
             if (parseFloat(aData[10]) >= cutoff) 
             $("td:eq(4)", nRow).css("font-weight", "bold"); 
             }'))) 
    }) 
``` 

答えて

関連する問題