Я имею дело с этой проблемой .Я пробовал некоторые решения css, но мне не удалось ее решить.
Наконец я решил навести курсор на каждую ячейку, чтобы отобразить имена строк (первый столбец) и столбцы (заголовок).
Следующий код выполняет трюк
,
shinyApp(
ui = fluidPage(
DT::dataTableOutput("mtcarsTable")
),
server = function(input, output) {
output$mtcarsTable <- DT::renderDataTable({
DT::datatable(datasets::mtcars[,1:3],
extensions = c('FixedColumns'), selection=list(mode="single", target="cell"), class = 'cell-border stripe', escape = F ,
options = list(rowCallback = JS(
"function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {",
"var full_text = aData[0] + ','+ aData[1];",
"var headers = Array.prototype.slice.apply(document.querySelectorAll('th'));",
"$('td', nRow).each(function(i) {
this.title = [aData[0], headers[i].innerText].filter(Boolean).join(', ');
});",
"}")
)
)
})
}
)
К сожалению, это кажется несовместимым с formatStyle:
shinyApp(
ui = fluidPage(
DT::dataTableOutput("mtcarsTable")
),
server = function(input, output) {
output$mtcarsTable <- DT::renderDataTable({
DT::datatable(datasets::mtcars[,1:3],
extensions = c('FixedColumns'), selection=list(mode="single", target="cell"), class = 'cell-border stripe', escape = F ,
options = list(rowCallback = JS(
"function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {",
"var full_text = aData[0] + ','+ aData[1];",
"var headers = Array.prototype.slice.apply(document.querySelectorAll('th'));",
"$('td', nRow).each(function(i) {
this.title = [aData[0], headers[i].innerText].filter(Boolean).join(', ');
});",
"}")
)
) %>%
formatStyle(columns = 1, backgroundColor = styleInterval(c(19,20,22), c('red','green','yellow', 'black')))
})
}
)
Когда я выполняю этот дополнительный шаг,Я не получаю ни ошибки, ни отображаемых данных.
Я ищу либо: возможность смешивать rowCalllback и Styleinterval, либо вообще лучшее решение, позволяющее пользователю узнать, где именно он находится на большомдата.
Заранее спасибо.