Skip to content

Commit

Permalink
datagrid: send data aftr sort
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Mar 12, 2024
1 parent 8e70168 commit 61de1ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/zzz-grid-drag.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ server <- function(input, output, session) {
datagrid(list(
"Variable 1" = 1:10,
"Variable 2" = LETTERS[1:10]
), draggable = TRUE)
), draggable = TRUE, data_as_input = TRUE)
})

output$drag <- renderPrint({
Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/datagrid.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions srcjs/widgets/datagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ HTMLWidgets.widget({
data: grid.getData(),
colnames: x.colnames,
}, {priority: "event"});
grid.on("afterSort", function (ev) {
Shiny.setInputValue(el.id + "_data:datagridEdit", {
data: ev.instance.getData(),
colnames: x.colnames,
}, {priority: "event"});
});
if (x.validationInput === true) {
Shiny.setInputValue(
el.id + "_validation:datagridValidation",
Expand Down

0 comments on commit 61de1ac

Please sign in to comment.