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

Disable User-sortable Columns #911

Open
jmoppel opened this issue Apr 4, 2023 · 1 comment
Open

Disable User-sortable Columns #911

jmoppel opened this issue Apr 4, 2023 · 1 comment

Comments

@jmoppel
Copy link

jmoppel commented Apr 4, 2023

Hello, thanks for the terrific library. It has worked great with Bootstrap Table! Is there a way to remove the end user's ability to sort columns by clicking on column headers (i.e., de-linkify the column headers), while still being able to sort the columns in the Table class and via URL parameters?

The goal is to sort the table by a default field (e.g., name) and then hand the HTML off to Bootstrap Table, for the more dynamic things. I've looked around the documentation a fair bit, but nothing stated it ignored orderable (which turns off sorting everywhere, it seems). It looks like turning off clickable headers using the Column API might be possible. However, it was a bit difficult to make out how to go about it (assuming this is the right track at all) since there weren't any examples that I could find in the Columns section. I would be grateful for guidance on the best way to solve this problem. Thanks again!

@Alexandre-petitjean
Copy link

You can disable this in the init of your custom Column

class PictureColumn(tables.Column):

    def __init__(self, *args, **kargs):
        super().__init__(*args, **kargs)
        self.orderable = False

Or you can pass the arg to the column in the table definition.

class ConsumableTable(tables.Table):
    picture = PictureColumn(accessor="get_picture_url", orderable=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants