Closed isthisthat closed 8 months ago
I'm not sure what you meant by "It repeats the row header for each row (even when the grouping column has the same value)". Here is my minimal reprex:
d = data.frame(
Group = rep(xfun::n2w(1:3), length.out = 26),
a = sample(26), b = letters, c = factor(rep(c('a', 'b'), 13)),
d = Sys.Date() + 1:26, e = Sys.time() + 1000 * (1:26), row.names = LETTERS
)
DT::datatable(
d, rownames = FALSE,
options = list(rowGroup = list(dataSrc = 0), order = list(list(0, 'asc'))),
extensions = 'RowGroup'
)
DT::datatable(
d, rownames = TRUE,
options = list(rowGroup = list(dataSrc = 1), order = list(list(1, 'asc'))),
extensions = 'RowGroup'
)
Sorry that was poor triaging on my part. There is no issue with rownames
. The actual issue is with colReorder
and rowGroup
it seems. Here is a reproducible example:
renderDT({
datatable(setDT(data.frame(A=c(1,2,3,4),B=c(5,6,7,8),G=c("a","a","b","b"))), rownames=FALSE,
options = list(
colReorder = TRUE,
rowGroup = list(dataSrc = 2)
),
extensions = c("ColReorder", "RowGroup")
)
}, server=TRUE)
Initially the table is row-grouped by G
. When you move column A
(or any column) to the place where column G
was, and sort by that column, the row-grouping changes to that column, for example:
d = data.frame(
A = c(1, 2, 3, 4),
B = c(5, 6, 7, 8),
G = c("a", "a", "b", "b")
)
DT::datatable(
d, rownames = FALSE,
options = list(
colReorder = TRUE,
rowGroup = list(dataSrc = 2)
),
extensions = c("ColReorder", "RowGroup")
)
Okay, I see the problem now. Technically it shouldn't be too difficult to fix. We need to reset the dataSrc
attribute for the rowGroup
extension in the column-reorder
event:
I'm not sure if anyone wants to help. I don't have time to work on it at the moment, but can take another look in a couple of months if no one sends a PR.
Our great helper @mikmart has made it again! Now you can try the development version:
remotes::install_github('rstudio/DT')
I can confirm it works! Thank you so much @mikmart , you're on a roll!!
Great, thanks for testing!
The
RowGroup
extension does not appear to work properly whenrownames = TRUE
. It repeats the row header for each row (even when the grouping column has the same value). I'm aware of the support issues with DT, just filing this FYI. Thank youBy filing an issue to this repo, I promise that
xfun::session_info('DT')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/DT')
.I understand that my issue may be closed if I don't fulfill my promises.