Skip to content

Commit

Permalink
changes of option names for DataTables 1.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Aug 1, 2014
1 parent d30ec85 commit 6f2a561
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions 012-datatables/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ shinyServer(function(input, output) {
# sorted columns are colored now because CSS are attached to them
output$mytable2 <- renderDataTable({
mtcars
}, options = list(bSortClasses = TRUE))
}, options = list(orderClasses = TRUE))

# customize the length drop-down menu; display 5 rows per page by default
output$mytable3 <- renderDataTable({
iris
}, options = list(aLengthMenu = c(5, 30, 50), iDisplayLength = 5))
}, options = list(lengthMenu = c(5, 30, 50), pageLength = 5))

})
12 changes: 6 additions & 6 deletions 018-datatable-options/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ We can customize DataTables through the `options` argument of
`shiny::renderDataTable()`. Below is a brief explanation of the 6 examples
above:

1. the option `iDisplayLength = 10` changes the default number of rows to
1. the option `pageLength = 10` changes the default number of rows to
display from 25 to 10;

1. the option `aLengthMenu = list(c(5, 15, -1), list('5', '15', 'All'))` sets
1. the option `lengthMenu = list(c(5, 15, -1), list('5', '15', 'All'))` sets
the length menu items (in the top left corner); it can be either a numeric
vector (e.g. `c(5, 10, 30, 100)`), or a list of length 2 -- in the latter
case, the first element is the length options, and the second element
contains their labels to be shown in the menu;

1. `bPaginate = FALSE` disables pagination, i.e. all records in the data are
shown at once; alternatively, you can set `iDisplayLength = -1`;
1. `paging = FALSE` disables pagination, i.e. all records in the data are
shown at once; alternatively, you can set `pageLength = -1`;

1. `bFilter = FALSE` disables searching, and no searching boxes will be shown;
1. `searching = FALSE` disables searching, and no searching boxes will be shown;

1. the option `bSearchable` can be configured for individual columns, so that
1. the option `searchable` can be configured for individual columns, so that
we can selectively turn off searching for certain columns;

1. any character strings wrapped in `I()` will be treated as literal JavaScript
Expand Down
28 changes: 13 additions & 15 deletions 018-datatable-options/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@ library(shiny)
shinyServer(function(input, output) {

# display 10 rows initially
output$ex1 <- renderDataTable(iris, options = list(iDisplayLength = 10))
output$ex1 <- renderDataTable(iris, options = list(pageLength = 10))

# -1 means no pagination; the 2nd element contains menu labels
output$ex2 <- renderDataTable(iris, options = list(
aLengthMenu = list(c(5, 15, -1), c('5', '15', 'All')),
iDisplayLength = 15
lengthMenu = list(c(5, 15, -1), c('5', '15', 'All')),
pageLength = 15
))

# you can also use bPaginate = FALSE to disable pagination
output$ex3 <- renderDataTable(iris, options = list(bPaginate = FALSE))
# you can also use paging = FALSE to disable pagination
output$ex3 <- renderDataTable(iris, options = list(paging = FALSE))

# turn off filtering (no searching boxes)
output$ex4 <- renderDataTable(iris, options = list(bFilter = FALSE))
output$ex4 <- renderDataTable(iris, options = list(searching = FALSE))

# turn off filtering on individual columns
# turn off filtering on individual columns (3rd and 4th column)
output$ex5 <- renderDataTable(iris, options = list(
aoColumns = list(list(bSearchable = TRUE), list(bSearchable = TRUE),
list(bSearchable = FALSE), list(bSearchable = FALSE),
list(bSearchable = TRUE)),
iDisplayLength = 10
columnDefs = list(list(targets = c(3, 4) - 1, searchable = FALSE)),
pageLength = 10
))

# write literal JS code in I()
output$ex6 <- renderDataTable(
iris,
options = list(fnRowCallback = I(
'function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
options = list(rowCallback = I(
'function(row, data) {
// Bold cells for those >= 5 in the first column
if (parseFloat(aData[0]) >= 5.0)
$("td:eq(0)", nRow).css("font-weight", "bold");
if (parseFloat(data[0]) >= 5.0)
$("td:eq(0)", row).css("font-weight", "bold");
}'
))
)
Expand Down
2 changes: 1 addition & 1 deletion 021-selectize-plot/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ shinyServer(function(input, output, session) {
# show raw data
output$rawdata <- renderDataTable(
cbind(State = rownames(USArrests), USArrests),
options = list(iDisplayLength = 10)
options = list(pageLength = 10)
)

})
2 changes: 1 addition & 1 deletion 052-navbar-example/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ shinyServer(function(input, output, session) {

output$table <- renderDataTable({
cars
}, options=list(iDisplayLength=10))
}, options=list(pageLength=10))
})

0 comments on commit 6f2a561

Please sign in to comment.