-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtable.R
60 lines (57 loc) · 1.33 KB
/
table.R
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
#' @export
spyctable <- function(data, format = "default", na = "zero") {
list(
data = data,
format = format,
na = na
)
}
#' @export
renderSpyCTable <- function(expr, env = parent.frame(), quoted = FALSE, id) {
func <- shiny::exprToFunction(expr, env, quoted)
session <- shiny::getDefaultReactiveDomain()
shiny::reactive({
to_render <- func()
list(
html = jsonlite::unbox(
build_spyctable_html(
to_render$data,
colnames(to_render$data),
nrow(to_render$data),
to_render$format,
to_render$na,
id = shiny::getCurrentOutputInfo()$name
)
)
)
})
}
#' @export
spyCTableOutput <- function(id, scroll_y = "50vh") {
shiny::tagList(
htmltools::htmlDependency(
name = "spyctable",
version = "0.1.0",
package = "spyctable",
src = "table",
script = "index.js"
),
htmltools::htmlDependency(
name = "datatables",
version = "2.0.8",
package = "spyctable",
src = "datatables",
script = "datatables.min.js",
stylesheet = "datatables.min.css"
),
shiny::div(
class = "spyctable",
id = id,
`scroll-y` = scroll_y
)
)
}
#' @export
get_spyc_table_selection <- function(input, dataset) {
filter_from_values_vec(as.character(input), dataset)
}