Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to remove parenthesis from groups? #94

Closed
algo-se opened this issue Nov 11, 2020 · 4 comments
Closed

Is it possible to remove parenthesis from groups? #94

algo-se opened this issue Nov 11, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@algo-se
Copy link

algo-se commented Nov 11, 2020

Using groupBy adds a default count to the group:

reactable(iris, 
  groupBy = "Species", 
  columns = list(
    Sepal.Length = colDef(aggregate = "count"),
    Sepal.Width = colDef(aggregate = "mean"),
    Petal.Length = colDef(aggregate = "sum"),
    Petal.Width = colDef(aggregate = "max")
    )
)

image
Is it possible to hide the default count? I´ve tried using custom JS with no success:

reactable(iris, 
          groupBy = "Species", 
          columns = list(
            Species = colDef(
              aggregated = JS("function(cellInfo) {
                return cellInfo.slice(0,-4);
              }"),
            ),
            Sepal.Length = colDef(aggregate = "count"),
            Sepal.Width = colDef(aggregate = "mean"),
            Petal.Length = colDef(aggregate = "sum"),
            Petal.Width = colDef(aggregate = "max")
          )
)
reactable(iris, 
          groupBy = "Species", 
          defaultColDef = colDef(
            aggregated = JS("function(cellInfo) {
              return cellInfo.slice(0,-4)
            }")
          ),
          columns = list(
            Sepal.Length = colDef(aggregate = "count"),
            Sepal.Width = colDef(aggregate = "mean"),
            Petal.Length = colDef(aggregate = "sum"),
            Petal.Width = colDef(aggregate = "max")
          )
)

Best regards.

@glin
Copy link
Owner

glin commented Nov 11, 2020

It's not possible today, even with custom JS, but it's been requested before (#33). I'll put it on the list to include for the next release. The usage will probably look something like this:

reactable(
  iris,
  groupBy = "Species",
  columns = list(
    Species = colDef(
      # Custom renderer for a grouped cell
      grouped = JS("function(cellInfo) {
        // Display just the cell value
        return cellInfo.value
        
        // Or display the cell value with the sub row count (the default)
        return cellInfo.value + '(' + cellInfo.subRows.length + ')'
      }")
    )
  )
)

@algo-se
Copy link
Author

algo-se commented Nov 11, 2020 via email

@glin glin added the enhancement New feature or request label Feb 6, 2021
@glin
Copy link
Owner

glin commented May 15, 2021

It's now possible to customize grouped cell rendering in the development version, using the syntax from above (1297d0c).

  • colDef() gains a grouped argument to customize rendering for grouped cells in groupBy columns (#33, #94, #148).

I added some live examples of this to the docs: https://glin.github.io/reactable/articles/examples.html#grouped-cell-rendering

@mdubel
Copy link

mdubel commented Jan 18, 2022

With the current version 0.2.3 it can be achieved with custom css, see here: https://stackoverflow.com/a/70755757/9239948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants