0
我有一個閃亮的應用程序,我想根據上一行中同一單元格的值修改顯示的數據和/或單元格的屬性。在基於前一行的R DT :: datatable中修改單元格
在我的代碼中,我根據rowCallback中的數據[0]的值格式化了整行。
output$result <- DT::renderDataTable(tabledata(),
class = c('compact'),
rownames = FALSE,
server = FALSE,
escape = TRUE,
extensions = options = list(
rowCallback=JS("
function (row, data, index) {
var string=data[1], substring = 'sub total';
if (data[0]=='Grand Total') {
$(row).css('background-color', '#DEDEDE'), $(row).css('font-weight', 'bold') ;
}
else if (data[0].includes('sub total')) {
$(row).css('font-weight', 'bold');
}
}"
)
)
)
我可以實現基於相同的細胞的使用的回調函數一個先前行中的值的數據[0]單元的修改?
不知道..但是你可以嘗試與得到一定值的指數東西..然後把這個指標值-1,並設置屬性 – zwep
您好@zwep ....我一直在顛倒與傳遞給rowCallback行的索引,但不能完全得到它。 – Martyn