Hi
I've been developing a site over the past few weeks using CodeIgniter as the framework. It's a great framework, however I've been puzzling over the best way to accomplish something which in a lot of other frameworks / languages is relatively simple: sortable tables.
CodeIgniter switches off query strings by default, because your URLs contain method parameters.
so a URL might look like: /controller/method/param1/param2
So you might think that you could just add in 'sortBy' and 'sortOrder' as two additional parameters to the controller method. I don't particularly want to do that, mainly because I want to have a re-usable control. When you use query string parameters, PHP can easily tell you whether there is a parameter called 'sortBy'. However when you're using URL based parameters, it will vary with each controller.
So I was wondering what my options were, as far as I can see it it's something like this:
- Pass in my 'sortBy' and 'sortOrder' parameters, just suck it up and develop some less-than-reusable component for it.
- Have an additional controller which will store the sortBy and sortOrder in the session - although it would have to know where you came from and send you back to the original page.
- Have some kind of AJAX function which would call the controller above and then reload the page.
- Hack CodeIgniter to turn query strings back on! [Actually if this is the only option, any links to how to do this would be appreciated...]
I just can't quite believe such a simple task would present such a problem! Am I missing something? Anyone have any recommendations?
Edit for clarification: I love jQuery (and I'm already using it on the site) so TableSorter is a good option, however I would like to do server-side sorting as there are some pages with potentially large numbers of results (including pagination).
Thanks very much! - Phill