Skip to content

Commit

Permalink
Maintain RowGroup dataSrc when moved with ColReorder (#1121)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikmart authored Jan 25, 2024
1 parent 2476bf7 commit f5a054d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGES IN DT VERSION 0.32

- Fixed a bug that caused the column used for grouping with the RowGroup extension to change when relocated by the ColReorder extension (thanks, @isthisthat, @mikmart, #1109).

- Fixed the bug that `replaceData()` failed to work with data that has no column names (thanks, @mmuurr, #1108).

- `updateSearch()` now sets the slider values based on the new search string for numeric columns (thanks, @mikmart, #1110).
Expand Down
9 changes: 9 additions & 0 deletions inst/htmlwidgets/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ HTMLWidgets.widget({
var table = $table.DataTable(options);
$el.data('datatable', table);

if ('rowGroup' in options) {
// Maintain RowGroup dataSrc when columns are reordered (#1109)
table.on('column-reorder', function(e, settings, details) {
var oldDataSrc = table.rowGroup().dataSrc();
var newDataSrc = details.mapping[oldDataSrc];
table.rowGroup().dataSrc(newDataSrc);
});
}

// Unregister previous Crosstalk event subscriptions, if they exist
if (instance.ctfilterSubscription) {
instance.ctfilterHandle.off("change", instance.ctfilterSubscription);
Expand Down

0 comments on commit f5a054d

Please sign in to comment.