Skip to content

Feature request: Including sort order parameter in ajaxUrl #155

Closed
trevorbernard opened this Issue Oct 15, 2012 · 8 comments

4 participants

@trevorbernard

I'm running into an issue where I want sort to be applied on the whole dataset and not just the particular page I'm on when I'm using ajax and pagination.

@thezoggy
Collaborator

just pass the param to your app that serves up the content?

@trevorbernard

Yup that's what I want to do but there is a little bit of work to get it working.

https://github.com/Mottie/tablesorter/blob/master/addons/pager/jquery.tablesorter.pager.js#L250

The library would have to know about it.

@Mottie
Owner
Mottie commented Oct 15, 2012

Hmm, so you'd need the column and direction (0 = desc, 1 = asc) added?

So the URL would have to look something like this?

// sortList
[ [0,0], [1,0] ]

// url
col[0]=0&col[1]=0 
@trevorbernard

Yup, something like that

@Mottie
Owner
Mottie commented Oct 15, 2012

Ok cool. I'll look into add something like this soon.

@Mottie
Owner
Mottie commented Oct 17, 2012

Hi @trevorbernard!

Tell me what you think of the parameter I added. Basically you add this to the url {sortList:xyz}, where xyz is the parameter name to add to the url. So this url string

"http://mydatabase.com?page={page}&size={size}&{sortList:xyz}"

that has page number of 2, size of 10 and a sortList value of [[2,0],[3,0]] becomes

"http://mydatabase.com?page=2&size=10&xyz[2]=0&xyz[3]=0"

If no sort is applied to the table, the url string will only return parameter name:

"http://mydatabase.com?page=2&size=10&xyz"
@trevorbernard

Looks good. I won't have time to test it out until tomorrow morning though.

@four43
four43 commented Oct 17, 2012

You guys are on this, awesome. I've been looking into extending the AJAX portion of the pager plugin to handle more REST-style parameters and sorting. Glad to see there is other interest in this as well.

@Mottie Mottie closed this Nov 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.