Giter VIP home page Giter VIP logo

Comments (6)

yihui avatar yihui commented on July 22, 2024 1

Our great helper @mikmart has made it again! Now you can try the development version:

remotes::install_github('rstudio/DT')

from dt.

isthisthat avatar isthisthat commented on July 22, 2024 1

I can confirm it works! Thank you so much @mikmart , you're on a roll!!

from dt.

yihui avatar yihui commented on July 22, 2024

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'
)

rownames = FALSE

image

rownames = TRUE

image

from dt.

isthisthat avatar isthisthat commented on July 22, 2024

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:
image

from dt.

yihui avatar yihui commented on July 22, 2024
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.

from dt.

mikmart avatar mikmart commented on July 22, 2024

Great, thanks for testing!

from dt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.