我试图修改当前的rowcallback代码,使其成为实例列1和4的目标:最后一列。
"for (i = 3; i < data.length; i++) {",
我试过这样写:
"for (i = 1 | i = 3; i < data.length; i++) {",
library(DT)
Table_opts <- list(
dom = 'Bfrtip',
searching = F,
pageLength = 50,
searchHighlight = TRUE,
colReorder = TRUE,
fixedHeader = TRUE,
buttons = c('csv', 'print'),
paging = TRUE,
deferRender = TRUE,
scrollX = T,
scrollY = 310,
rowCallback = JS(
"function(row, data) {",
"for (i = 3; i < data.length; i++) {",
"if (data[i]>1 | data[i]<0){",
"$('td:eq('+i+')', row).html(data[i].toExponential(1));",
"}",
"}",
"}")
)
DT::datatable(mtcars, rownames = F, selection = "single",
extensions = c('Buttons', 'FixedHeader', 'ColReorder','Scroller'), options = Table_opts)