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

column sortable option must fallback to True #216

Open
typemytype opened this issue Sep 9, 2024 · 4 comments
Open

column sortable option must fallback to True #216

typemytype opened this issue Sep 9, 2024 · 4 comments

Comments

@typemytype
Copy link
Member

sortable = columnDescription.get("sortable")

now it falls back to None

@typesupply
Copy link
Member

Should it fall back to True or False? It was off by default in List because back when vanilla used Cocoa Bindings sorting was quite difficult and in some instances would modify the represented data. I don't know if we should preserve the off-by-default setting or not.

@gferreira2
Copy link

thanks for looking into it. it would be nice if it could behave just like vanilla.List, falling back to whatever value is set in the parent allowsSorting argument:

import ezui
import vanilla

myTableItems = [
    dict(name="A", value=8),
    dict(name="X", value=9),
    dict(name="B", value=2),
    dict(name="D", value=7),
    dict(name="Z", value=3),
]

class DemoTable(ezui.WindowController):

    def build(self):
        content = """
        |------|-------| 
        | name | value | @myTable
        |------|-------|
        """
        descriptionData = dict(
            myTable=dict(
                items=myTableItems,
                allowsSorting=True,
                columnDescriptions=[
                    dict(
                        identifier="name",
                        title="name",
                    ),
                    dict(
                        identifier="value",
                        title="value",                      
                    ),
                ],
            ),
        )
        self.w = ezui.EZWindow(
            title="ezui Table",
            size=(300, 200),
            content=content,
            descriptionData=descriptionData,
            controller=self
        )

    def started(self):
        self.w.open()

class DemoList2:

    def __init__(self):
        self.w = vanilla.Window((300, 200), title='vanilla List2')

        self.w.list = vanilla.List2(
            (10, 10, -10, -10),
            items=myTableItems,
            allowsSorting=True,
            columnDescriptions=[
                dict(
                    identifier="name",
                    title="name",
                ),
                dict(
                    identifier="value",
                    title="value",                      
                ),
            ],
        )
        self.w.open()

class DemoList:

    def __init__(self):
        self.w = vanilla.Window((300, 200), title='vanilla List')

        self.w.list = vanilla.List(
            (10, 10, -10, -10),
            myTableItems,
            allowsSorting=True,
            columnDescriptions=[
                dict(
                    identifier="name",
                    title="name",
                ),
                dict(
                    identifier="value",
                    title="value",                      
                ),
            ],
        )
        self.w.open()

DemoTable()
DemoList2()
DemoList()

@typemytype
Copy link
Member Author

the documentation mentioned the fallback should be True and this follows the old vanilla List behaviour.

| *"sortable"* (optional) | A boolean representing that this column allows the user |
| | to sort the table by clicking the column's header. |
| | The fallback is `True`. If a List is set to disallow |
| | sorting the column level settings will be ignored. |

A vanillaList2 has support to disable specific columns not to be sorted even if the global allowsSorting is True.

@ryanbugden
Copy link

Was there any update on this? There are some EZUI-based tools that I think would be greatly enhanced with the ability to sort table results. Thanks!

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

4 participants