I have an interesting question. How can I get the effect where I can select rows in a DT (DataTable) built-in R-markdown across pages and filtering. This would be really helpful as selectedrows across filter, pages and searches in a large dataframe can then be easily exported with the integrated buttons to for example CSV. I need the javacript below translated into R.
Here it is done in Javascript; https://datatables.net/examples/server_side/select_rows.html
Here is my DT built in R-markdown:
#DT table of departures with detailed filtering
Customer_card_DT <- DT:: datatable(Customercard_all,
#container = sketch,
filter = "top", #adds filter options to each column (filter can be "top" or "bottom")
class = "cell-border stripe hover order-column", #adds some basic styling to the table and reducing white-space with compact, highlight on mouseover with hover, and hightlight the column that is used for filtering with order-column
#caption = "Customer Card",
rownames = F, #Removing row name indexes
editable = TRUE, #allows the table to be edited in the final output
#colnamnes code below does nothing after adding colnames in container
# colnames = c("PO reg", "Art", "Product", "QTY", "Destination", "ETA", "Days left", "Tracking", "Change in ETA",
# "Type", "Containers", "Purch.value"), #changes column names in the final output
extensions = c("Buttons", "KeyTable", "Select"), #adds buttons at the top of the table which allow the user to export the data
selection = 'none',
options = list(
#Use the code below to hide all columns that are basicly default in a SPO upload. It shows up on export anyways.
#columnDefs = list(list(visible=FALSE, targets=c(13,14))),
pageLength = 30,
autoWidth = TRUE,
keys = TRUE, #For KeyTable entension which creates border of current cell and that enables excel style navigation between cells
dom = 'Bfrtip', #For buttons
select = list(style = 'os', items = 'row'),
buttons = c('copy', 'csv', 'excel', 'pdf', 'print', I('colvis'), "selectCells", "selectRows", "selectNone"))) #adds buttons at the top of the table which allow the user to access different functionalities
Customer_card_DT
Thanks very much in advance!