Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain RowGroup dataSrc when moved with ColReorder #1121

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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