-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommunities.qmd
66 lines (59 loc) · 1.49 KB
/
communities.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: Communities
execute:
echo: false
---
```{r}
library(reactable)
library(htmltools)
```
```{r}
communities <- read.csv("communities.csv")
```
```{r}
filter_fct <- function(values, name) {
tags$select(
tags$option(value = "", "All"),
purrr::map(unique(values), tags$option),
onchange = glue::glue(
"Reactable.setFilter(
'communities-tbl',
'{name}',
event.target.value // This is the value of the dropdown menu
)"
),
style = "width: 100%; height: 28px;"
)
}
exact_match_fct <- function() {
JS("(rows, columnId, filterValue) => {
return rows.filter(row => row.values[columnId] === filterValue)
}")
}
```
```{r}
reactable(
communities,
columns = list(
Community.name = colDef(name = "Community name"),
Description = colDef(name = "Description"),
Website = colDef(cell = function(value) {
tags$a(href = value, target = "_blank", value)
}),
Region = colDef(name = "Region",
filterInput = filter_fct,
# filterMethod contains some JavaScript code
# Specifies that the filter should be an exact match
# exact_match_fct is defined above
filterMethod = exact_match_fct()
),
Theme = colDef(name = "Theme",
filterInput = filter_fct,
filterMethod = exact_match_fct()
)
),
filterable = TRUE,
defaultPageSize = 20,
elementId = "communities-tbl"
)
```