diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
index 19fd2c7c71..4a5b212248 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
@@ -170,13 +170,31 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa
dt_parameters[ "buttons" ] = ['clear_filter'];
- let included_columns = table_settings.columns.filter(c => !c.cannot_be_toggled);
+ // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT settings
+ // But ideally should be retrieved using table.data()
+ let use_names = dt_parameters.bKohaColumnsUseNames;
+ let included_columns = [];
+ if (table_settings) {
+ if (use_names) {
+ // bKohaColumnsUseNames is set, identify columns by their data-colname
+ included_columns = table_settings.columns
+ .filter(c => !c.cannot_be_toggled)
+ .map(c => "[data-colname='%s']".format(c.columnname))
+ .join(",");
+ } else {
+ // Not set, columns are ordered the same than in the columns settings
+ included_columns = table_settings.columns
+ .map((c, i) => (!c.cannot_be_toggled ? i : null))
+ .filter(i => i !== null);
+ }
+ }
+
if( included_columns.length > 0 ){
dt_parameters[ "buttons" ].push(
{
extend: 'colvis',
fade: 100,
- columns: included_columns.map(c => "[data-colname='%s']".format(c.columnname)).join(','),
+ columns: included_columns,
className: "columns_controls",
titleAttr: _("Columns settings"),
text: ' ' + _("Columns") + '',