diff --git a/NEWS b/NEWS index c1d56a0..575edc1 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ rhandsontable 0.3.2 * Added rowHeaderWidth to hot_table to allow specifying the rowHeader column width +* Added digits to rhandsontable, which is passed to jsonlite::toJSON + * Fixed shiny bug with mixed numeric and character column names (#77) rhandsontable 0.3.1 diff --git a/R/rhandsontable.R b/R/rhandsontable.R index 97425bb..9a626f3 100644 --- a/R/rhandsontable.R +++ b/R/rhandsontable.R @@ -18,6 +18,7 @@ #' This can be used with shiny to tie updates to a selected table cell. #' @param width numeric table width #' @param height numeric table height +#' @param digits numeric passed to \code{jsonlite::toJSON} #' @param ... passed to hot_table #' @examples #' library(rhandsontable) @@ -32,7 +33,7 @@ rhandsontable <- function(data, colHeaders, rowHeaders, comments = NULL, useTypes = TRUE, readOnly = NULL, selectCallback = FALSE, - width = NULL, height = NULL, ...) { + width = NULL, height = NULL, digits = 4, ...) { if (missing(colHeaders)) colHeaders = colnames(data) if (missing(rowHeaders)) @@ -101,7 +102,8 @@ rhandsontable <- function(data, colHeaders, rowHeaders, comments = NULL, } x = list( - data = jsonlite::toJSON(data, na = "string", rownames = FALSE), + data = jsonlite::toJSON(data, na = "string", rownames = FALSE, + digits = digits), rClass = rClass, rColClasses = rColClasses, rColnames = as.list(colnames(data)), @@ -186,7 +188,7 @@ hot_table = function(hot, contextMenu = TRUE, stretchH = "none", if (!is.null(customBorders)) hot$x$customBorders = customBorders if (!is.null(enableComments)) hot$x$comments = enableComments if (!is.null(overflow)) hot$x$overflow = overflow - if (!is.null(rowHeaderWidth)) hot$x$rowHeaderWidth = rowHeaderWidth + if (!is.null(rowHeaderWidth)) hot$x$rowHeaderWidth = rowHeaderWidth if ((!is.null(highlightRow) && highlightRow) || (!is.null(highlightCol) && highlightCol)) diff --git a/man/rhandsontable.Rd b/man/rhandsontable.Rd index 9875b00..2957878 100644 --- a/man/rhandsontable.Rd +++ b/man/rhandsontable.Rd @@ -6,7 +6,7 @@ \usage{ rhandsontable(data, colHeaders, rowHeaders, comments = NULL, useTypes = TRUE, readOnly = NULL, selectCallback = FALSE, - width = NULL, height = NULL, ...) + width = NULL, height = NULL, digits = 4, ...) } \arguments{ \item{data}{a \code{data.table}, \code{data.frame} or \code{matrix}} @@ -33,6 +33,8 @@ This can be used with shiny to tie updates to a selected table cell.} \item{height}{numeric table height} +\item{digits}{numeric passed to \code{jsonlite::toJSON}} + \item{...}{passed to hot_table} } \description{