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

Dynamic SortAppend #3

Closed
Mottie opened this issue Sep 22, 2011 · 2 comments
Closed

Dynamic SortAppend #3

Mottie opened this issue Sep 22, 2011 · 2 comments

Comments

@Mottie
Copy link
Owner

Mottie commented Sep 22, 2011

I have a request to make a dynamic sortAppend. Here is the request:

I've got 3 column table(status, date, doc type), clicking on status should sort status & date, clicking on date should sort date & doc type, clicking on doc type should sort doc type & date.

So basically there is a default sortAppend option on the date column, but when the date colum is sorted first, add a different secondary sort.

The sortStart event doesn't work in this case because the sortList isn't defined at that point. The sortEnd event won't work, because, well the sort is already done.

@Mottie
Copy link
Owner Author

Mottie commented Sep 22, 2011

I added a new event named sortBegin which occurs immediately before the sort begins and after the sortList variable has been updated in the configure options. This allows us to dynamically change the sort order. Here is a demo and the basic code:

$('table').bind('sortBegin', function(e, tbl) {

    var c = tbl.config,
        list = c.sortList;

    // add third column sort if not the initial sort, otherwise sort second column
    // (zero based index)
    list.push((list[0] && list[0][0] !== 2) ? [2, 0] : [1, 0]);

});

@Mottie
Copy link
Owner Author

Mottie commented Oct 20, 2015

Feature added in b8e2b65.

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

No branches or pull requests

1 participant