Adding params to the pagination links .. or Sorting AND Pagination |
[eluser]jrlooney[/eluser]
So I am using the JavaScript method for sorting, so I have a table of data, User clicks on a column header and a JS sends the field name to a POST form. In the Model, if it sees 'sort' in input->post then it adds a ORDER BY clause to the query. However, let's say user clicks "Organization" so they want the table to sort on Org., then they click Page 2 in the pagination links. They lose the sort because it's not passed in the pagination link. Is there anyway to tack params onto the pagination links so that I can tack on something like /sort/organization ? thanks in advance Edit: Or does anyone have a better method of sorting and at the same time maintaining the pagination?
[eluser]jrlooney[/eluser]
nudge - as I think this could help others asking the same kinds of things
[eluser]xwero[/eluser]
I don't know how much data you table contains but maybe it's better to use a tablesorter in javascript that does the paginating? Another option is to use a cookie instead of a post to save the user defined sorting. Before you request the page you set the cookie values and you retrieve them in php for the db query.
[eluser]swanky[/eluser]
I'm not using JS for my sorting, but here's how I pass the sort params to the pagination links. In this example I'm sorting twice. First by body_style, and then by price, make, or model. Not sure if there is a better way, it's just how I've done it in the past. Code: function overview() You can see it online at http://www.westtnmotors.com/index.php/in...all/price/
[eluser]jrlooney[/eluser]
Ah thanks xwero, I shoulda thought to use a cookie. Even nicer if user has javascript disabled. thanks |
Welcome Guest, Not a member yet? Register Sign In |