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

Enables multisorting #36

Merged
merged 3 commits into from Jun 18, 2016

Conversation

Projects
None yet
2 participants
@balping
Contributor

balping commented Jun 7, 2016

New property multiSort added. If it's false (default), everything works like before

However when it's set to true, you can sort data by several selected columns. The most recent selected column has the smallest precedence.

The generated request looks like this: ?sort=id|desc,name|asc,email|asc

Of course to get this working, you'll need a backend which is able to parse the above format.

Please note that this commit breaks backwards compatibility a bit. Now if you want to initialise the sort-order property, it should be done with an array like this. Just wrap your previous object in an array.

[{
    field: 'name',
    direction: 'asc'
}]
Enables multisorting
New property `multiSort` added. If it's false (default), everything works like before

However when it's set to true, you can sort data by several selected columns. The most recent selected column has the smallest precedence.

The generated request looks like this: `?sort=id|desc,name|asc,email|asc`

Of course to get this working, you'll need a backend which is able to parse the above format.

Please note that this commit breaks backwards compatibility *a bit*. Now if you want to initialise the sort-order property, it should be done with an array like this. Just wrap your previous object in an array.

```
[{
    field: 'name',
    direction: 'asc'
}]
```
@ratiw

This comment has been minimized.

Owner

ratiw commented Jun 18, 2016

@balping Nice! Just got a chance to look at your PR.

The breaking change is ok to me and it is necessary.

But I think it would be better if you could make the multisort to react to modifier key (like holding the ctrl or alt key while checking on the title to enable multisort) and clicking on the title without this modifier key will reset the sort to that column only. This could be achieve by passing $event as another argument to orderBy method like so,

    <th @click="orderBy(field, $event)"

and in the method declaration

    orderBy: function(field, event) {
        //...
        if (this.multisort && event.ctrlKey) {
            //...
        }
    }

What do you think? Would love to hear your opinion on this. :)

@balping

This comment has been minimized.

Contributor

balping commented Jun 18, 2016

@ratiw

Yes, I agree with you, it's probably more user friendly this way, so I added this functionality.

In addition I made another commit that marks fields with stronger precedence with darker color, like so:

precedence

@ratiw ratiw merged commit c4189fd into ratiw:develop Jun 18, 2016

1 check passed

StyleCI The StyleCI analysis has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment