Open domsle opened 1 year ago
Hi, thanks for the report, looks like there are at least two issues going on here. One of which is definitely a bug, and the other is possibly a bug, but maybe also partially-intended behavior that should be documented:
cell
render function essentially does nothing because it's overridden by the selection checkbox/radio. When using defaultColDef
, the selection column is supposed to be included, but I guess it doesn't make sense to apply the cell
render function to it as well right now. However, it's probable that one day you'd be able to customize the selection cells using the cell
renderer of the selection column, so excluding it in defaultColDef
may not make sense either. At least for now, the selection column is documented, but we could add an additional warning that anything in defaultColDef
will apply to the selection column as well.logical(0)
, but you can also reproduce it minimally with:
reactable(data.frame(x = TRUE), columns = list(x = colDef(
cell = function() logical(0)
)))
reactable(data.frame(x = TRUE), columns = list(x = colDef( cell = function() c(1, 2) )))
With 1 and 2 combined, the errors are happening because the default cell render function is applying to the empty `.selection` column, and producing `logical(0)` results because the selection column values are all `NULL`, and `is.na(NULL)` produces `logical(0)` (weird, but that's R).
For now, you can work around this by adding a `NULL` check to your default `cell` render function:
```r
defaultColDef = colDef(
cell = function(x) {
if (is.null(x)) return()
ifelse(!is.na(x), format(x, digits = 3, nsmall = 3), "")
},
filterable = TRUE
)
or if you want to do it in the ifelse()
, this works too, but is kind of odd to read:
defaultColDef = colDef(
cell = function(x) {
ifelse(isTRUE(!is.na(x)), format(x, digits = 3, nsmall = 3), "")
},
filterable = TRUE
)
Hello,
When using the following code:
The result is that table does not appear at all. I get the following error in Chrome's console:![image](https://user-images.githubusercontent.com/18559095/207368368-90a9b9e1-fcb7-4395-abd3-a2b0be157bce.png)
I use the latest CRAN library (0.4.1) with R 4.1.2. Are you aware of this problem?