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

refreshOptions() error if columns in group are hidden #7588

Open
amiart opened this issue Oct 30, 2024 · 3 comments · Fixed by #7596
Open

refreshOptions() error if columns in group are hidden #7588

amiart opened this issue Oct 30, 2024 · 3 comments · Fixed by #7596
Labels
Bug Issues which are marked as Bug has PR Issues that has been fixed with a PR.

Comments

@amiart
Copy link
Contributor

amiart commented Oct 30, 2024

Bootstraptable version(s) affected

1.23.5

Description

refreshOptions() throws error Uncaught TypeError: column is undefined in updateFieldGroup() function if columns in group are hidden.

Example(s)

Working example:
https://live.bootstrap-table.com/code/amiart/18312

Hide 'Quantity' and 'Total' columns and then click 'RefreshOptions' button to see error.

Possible Solutions

No response

Additional Context

Windows 10
Firefox 132.0
Bootstrap 5

@amiart amiart added the Bug Issues which are marked as Bug label Oct 30, 2024
@wenzhixin wenzhixin added the has PR Issues that has been fixed with a PR. label Nov 5, 2024
@amiart
Copy link
Contributor Author

amiart commented Nov 5, 2024

#7596 resolves Uncaught TypeError: column is undefined error, but the columns are displayed incorrectly.
Hide 'Quantity' column and then click 'RefreshOptions' button to see the problem.

@wenzhixin wenzhixin reopened this Nov 5, 2024
@wenzhixin
Copy link
Owner

OK, thanks for your feedback.

@amiart
Copy link
Contributor Author

amiart commented Nov 27, 2024

My workaround:

Added this function in my code:

function setBootstrapTableOptions(table, options) {
    // WORKAROUND BUG #7588
    var hiddenColumns = $.map(table.bootstrapTable('getHiddenColumns'),
        function(col) { return col.field; });
    if (hiddenColumns.length > 0)
        table.bootstrapTable('showAllColumns');
    table.bootstrapTable('refreshOptions', options)
         .bootstrapTable('resetView', {});
    for (var i=0; i<hiddenColumns.length; ++i) {
        table.bootstrapTable('hideColumn', hiddenColumns[i]);
    }
}

And then if want to change bootstrap table options I use:

setBootstrapTableOptions($table, { showToggle: true });

instead of:

$table.bootstrapTable('refreshOptions', { showToggle: true });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug has PR Issues that has been fixed with a PR.
Projects
None yet
2 participants