Skip to content

Commit

Permalink
fix #169: do not actually write select options in <option></option>, …
Browse files Browse the repository at this point in the history
…but store them as JSON in the data-options attribute of <select> instead; this will significantly reduce the size of the data to be serialized
  • Loading branch information
yihui committed Mar 24, 2016
1 parent 158ae1c commit 864d779
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

- Fixed a bug that triggers a DataTables warning dialog box in the browser (thanks, @zross, https://github.com/WHOequity/who-heat/issues/229 and https://github.com/rstudio/shiny/issues/561)

- Factors will a huge number of levels may slow down the rendering of the table significantly (thanks, @vnijs, #169).

# CHANGES IN DT VERSION 0.1

- Initial CRAN release.
2 changes: 1 addition & 1 deletion R/datatables.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ filterRow = function(
if (t != 'disabled') tags$div(
tags$select(
multiple = 'multiple', style = 'width: 100%;',
lapply(d, function(x) tags$option(value = x, x))
`data-options` = jsonlite::toJSON(as.character(d))
),
style = 'width: 100%; display: none;'
)
Expand Down
6 changes: 5 additions & 1 deletion inst/htmlwidgets/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ HTMLWidgets.widget({
if ($input.val() === '') filter[0].selectize.setValue([]);
}
});
filter = $x.children('select').selectize({
var $input2 = $x.children('select');
filter = $input2.selectize({
options: $input2.data('options').map(function(v, i) {
return ({text: v, value: v});
}),
plugins: ['remove_button'],
hideSelected: true,
onChange: function(value) {
Expand Down

0 comments on commit 864d779

Please sign in to comment.