inst/examples/DT-deleteRows/server.R

library(shiny)
library(DT)

function(input, output, session) {

  output[["dtable"]] = renderDT({

    datatable(
      mtcars,
      extensions = "Buttons",
      options = list(
        dom = "Bfrtip",
        columnDefs = list(
          list(targets = "_all", className = "dt-center")
        ),
        buttons = list(
          list(
            extend = "collection",
            text = "Delete selected rows",
            action = JS(c(
              "function(e, dt, node, config) {",
              "  dt.rows('.selected').remove().draw();",
              "}"))
          )
        )
      )
    )

  }, server = FALSE)

}

Try the DT package in your browser

Any scripts or data that you put into this service are public.

DT documentation built on Oct. 5, 2023, 5:09 p.m.