diff --git a/DESCRIPTION b/DESCRIPTION index 9a81637a..b91146d3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: DT Type: Package Title: A Wrapper of the JavaScript Library 'DataTables' -Version: 0.31.1 +Version: 0.31.2 Authors@R: c( person("Yihui", "Xie", email = "xie@yihui.name", role = c("aut", "cre")), person("Joe", "Cheng", role = "aut"), diff --git a/NEWS.md b/NEWS.md index f6904cb0..24392537 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # CHANGES IN DT VERSION 0.32 +- Fixed the bug that `replaceData()` failed to work with data that has no column names (thanks, @mmuurr, #1108). # CHANGES IN DT VERSION 0.31 diff --git a/R/shiny.R b/R/shiny.R index 81ea528d..3e8b308a 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -473,6 +473,9 @@ reloadData = function( #' levels, and numeric columns should have the same or smaller range, #' otherwise the filters may never be able to reach certain rows in the data, #' unless you explicitly update the filters with \code{updateFilters()}. +#' +#' If the \code{ColReorder} extension is used, the new \code{data} must have +#' column names that match the original data column names exactly. #' @export replaceData = function(proxy, data, ..., resetPaging = TRUE, clearSelection = 'all') { dataTableAjax(proxy$session, data, ..., outputId = proxy$rawId) @@ -618,6 +621,9 @@ dataTablesFilter = function(data, params) { # index in data via its name because the two indices won't match when columns # are reordered via the colReorder extension imap = unlist(lapply(q$columns, function(col) { + # if data doesn't have column names (e.g., #1108), assume it's not reordered + # (which may not be true) + if (is.null(names(data))) return(0L) k = col[['name']] if (!is.character(k) || k == '') return(0L) i = match(k, names(data)) diff --git a/man/replaceData.Rd b/man/replaceData.Rd index f32c9836..5a2bea09 100644 --- a/man/replaceData.Rd +++ b/man/replaceData.Rd @@ -31,4 +31,7 @@ When you replace the data in an existing table, please make sure the levels, and numeric columns should have the same or smaller range, otherwise the filters may never be able to reach certain rows in the data, unless you explicitly update the filters with \code{updateFilters()}. + + If the \code{ColReorder} extension is used, the new \code{data} must have + column names that match the original data column names exactly. }