Skip to content

Commit

Permalink
close #275: document the problem with FixedColumns + row selection as…
Browse files Browse the repository at this point in the history
… a known issue

also close #378, close #422, close #439
  • Loading branch information
yihui committed Jan 5, 2018
1 parent a78fade commit e2343df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
3 changes: 2 additions & 1 deletion extensions.Rmd
Expand Up @@ -12,7 +12,8 @@ title: DataTables Extensions

Most **DataTables** extensions work on their own, but some may not work well when certain non-default features are enabled or used in Shiny apps. Below is a list of known issues:

- Column filters may not work well with the extensions `FixedColumns`, `FixedHeader`, and `Scroller` ([#41](https://github.com/rstudio/DT/issues/41));
- Column filters may not work well with the extensions `FixedColumns`, `FixedHeader`, and `Scroller` ([#34](https://github.com/rstudio/DT/issues/34), [#41](https://github.com/rstudio/DT/issues/41), [#422](https://github.com/rstudio/DT/issues/422));
- The `FixedColumns` extension does not work well with row selection: when you select rows in the fixed columns, the rows in other columns won't be selected, and vice ([#275](https://github.com/rstudio/DT/issues/275), [#395](https://github.com/rstudio/DT/issues/395), [#439](https://github.com/rstudio/DT/issues/439));
- These extensions do/may not work in Shiny apps:
- `ColReorder` will fail when you interact with the table, e.g., when you change the page ([#345](https://github.com/rstudio/DT/issues/345)), use column filters ([#160](https://github.com/rstudio/DT/issues/160)), or formatting functions ([#250](https://github.com/rstudio/DT/issues/250)).
- `KeyTable` ([#132](https://github.com/rstudio/DT/issues/132))
Expand Down
3 changes: 2 additions & 1 deletion extensions.html
Expand Up @@ -228,7 +228,8 @@ <h1 class="title toc-ignore">DataTables Extensions</h1>
<div class="panel-body">
<p>Most <strong>DataTables</strong> extensions work on their own, but some may not work well when certain non-default features are enabled or used in Shiny apps. Below is a list of known issues:</p>
<ul>
<li>Column filters may not work well with the extensions <code>FixedColumns</code>, <code>FixedHeader</code>, and <code>Scroller</code> (<a href="https://github.com/rstudio/DT/issues/41">#41</a>);</li>
<li>Column filters may not work well with the extensions <code>FixedColumns</code>, <code>FixedHeader</code>, and <code>Scroller</code> (<a href="https://github.com/rstudio/DT/issues/34">#34</a>, <a href="https://github.com/rstudio/DT/issues/41">#41</a>, <a href="https://github.com/rstudio/DT/issues/422">#422</a>);</li>
<li>The <code>FixedColumns</code> extension does not work well with row selection: when you select rows in the fixed columns, the rows in other columns won’t be selected, and vice (<a href="https://github.com/rstudio/DT/issues/275">#275</a>, <a href="https://github.com/rstudio/DT/issues/395">#395</a>, <a href="https://github.com/rstudio/DT/issues/439">#439</a>);</li>
<li>These extensions do/may not work in Shiny apps:
<ul>
<li><code>ColReorder</code> will fail when you interact with the table, e.g., when you change the page (<a href="https://github.com/rstudio/DT/issues/345">#345</a>), use column filters (<a href="https://github.com/rstudio/DT/issues/160">#160</a>), or formatting functions (<a href="https://github.com/rstudio/DT/issues/250">#250</a>).</li>
Expand Down
17 changes: 5 additions & 12 deletions libs/datatables-binding/datatables.js
Expand Up @@ -256,6 +256,11 @@ HTMLWidgets.widget({
};
}

var thiz = this;
if (instance.fillContainer) $table.on('init.dt', function(e) {
thiz.fillAvailableHeight(el, $(el).innerHeight());
});

var table = $table.DataTable(options);
$el.data('datatable', table);

Expand Down Expand Up @@ -659,18 +664,6 @@ HTMLWidgets.widget({
// run the callback function on the table instance
if (typeof data.callback === 'function') data.callback(table);

var thiz = this;
table.on('init', function(e) {
// fillContainer = TRUE behavior
if (instance.fillContainer) {
// calculate correct height
thiz.fillAvailableHeight(el, $(el).innerHeight());
}
// we need to force DT to recalculate column widths
// (otherwise all the columns are the same size)
thiz.adjustWidth(el);
});

// interaction with shiny
if (!HTMLWidgets.shinyMode && !crosstalkOptions.group) return;

Expand Down

0 comments on commit e2343df

Please sign in to comment.