Is there any way of setting the datatable options to reduce the column padding? This link suggested using autoWidth=TRUE
along with scrollX=TRUE
, but it doesn't work in my code.
As you can see in the image below there is a big gap between columns forcing the user to scroll across, which I'd prefer to avoid if possible. This link and this one have the same problem in java
Here's the code for rendering the datatable.
output$book_table <- DT::renderDT(RVTables$book %>%
filter(deal==as.numeric(input$deal_choice)),
selection = list(mode="single",selected=row_edited),
editable = TRUE,
rownames = FALSE,
options=list(
autoWidth=TRUE,
scrollX = TRUE,
ordering=FALSE,
pageLength=12,
scrollY = TRUE,
bLengthChange= FALSE,
searching=FALSE
)
)
Thanks for any help.
After some google searching I found the line of code class="compact cell-border",
which reduces the padding around column headers. Here is my code to render the table in case it helps anyone else.
output$book_table <- DT::renderDataTable({
DT::datatable(
deal_reactive(),
editable = TRUE,
rownames = FALSE,
class="compact cell-border",
selection = list(mode = "single",
target = "row",
selected = previous_row),
options = list(
dom="t",
autoWidth=TRUE,
scrollX = TRUE,
ordering=FALSE,
pageLength = 28,
bLengthChange= FALSE,
displayStart = previous_page,
searching=FALSE
)
)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With