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

Docs/connected-tables vignette #27

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions R/columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ set_auto_id <- function(data) {
return(data)
}

if (nrow(data) == 0) {
data$id <- numeric()
return(data)
}

data$id <- seq(1:nrow(data))
return(data)
}
Expand Down
1 change: 1 addition & 0 deletions R/tabulator_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ invoke_method <- function(widget, method_name, ...) {
}

#' Create a Tabulator Context Object
#'
#' A \code{tabulatorContext} object makes it possible to update your widget in a Shiny app.
#' @param output_id (character): A tabulator output id.
#' @param session shiny session object
Expand Down
6 changes: 6 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ tabulator(airquality) |>
tabulator(data = list(), spreadsheet = TRUE)
```

## Shiny

``` r
shiny::runGitHub("eodaGmbH/rtabulator", subdir = "examples/shiny/titanic")
```

## Documentation

[rtabulator docs](https://eodagmbh.github.io/rtabulator/)
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ tabulator(airquality) |>
tabulator(data = list(), spreadsheet = TRUE)
```

## Shiny

``` r
shiny::runGitHub("eodaGmbH/rtabulator", subdir = "examples/shiny/titanic")
```

## Documentation

[rtabulator docs](https://eodagmbh.github.io/rtabulator/)
51 changes: 51 additions & 0 deletions vignettes/articles/connectes-tables.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Connecting tables"
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
library(rtabulator)
```

With the setup option `movable_rows_connected_tables` you can move rows between two or more tables:

```{r}
sender_df <- head(iris, 3)
empty_df <- head(iris, 0)

tab_sender <- tabulator(
sender_df,
tabulator_options(
movable_rows = TRUE,
movable_rows_connected_tables = "#table-receiver",
movable_rows_receiver = "add",
movable_rows_sender = "delete",
placeholder = "All rows moved"
),
element_id = "table-sender"
)
tab_receiver <- tabulator(
empty_df,
tabulator_options(
placeholder = "Drag rows here"
),
element_id = "table-receiver"
)

tab_sender
tab_receiver
```

***

**Note**

In some browsers _moving rows functionality_ does not seem to work at the moment.

***
6 changes: 6 additions & 0 deletions vignettes/articles/shiny.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,9 @@ server <- function(input, output) {

shinyApp(ui = ui, server = server)
```

Run this example with:

```{r, eval=FALSE}
shiny::runGitHub("eodaGmbH/rtabulator", subdir = "examples/shiny/titanic")
```