Welcome Guest, Not a member yet? Register   Sign In
Sorting AND filtering using uri segments - how??
#1

[eluser]umbongo[/eluser]
I currently have a table of data, which is sortable by any column. The uri is /sort-column/[asc/desc]/offset. works great. But I also want to be able to filter by any column (eg. Column 2 > 10, <100, whilst column 3 is ='text-string', etc etc.). How do i handle this with URI strings? (if it is possible whilst remaining sensible)??
#2

[eluser]pbreit[/eluser]
This is a clear case where query strings would be preferable but it's tricky to get them working properly in CI.
#3

[eluser]umbongo[/eluser]
Thanks for the reply. What problems do i have to look out for / what problems does CI have with query strings?
#4

[eluser]natefons[/eluser]
can you give us an example uri that you mean?

im not really understanding everything you say.
#5

[eluser]Jeroen Brussich[/eluser]
http://www.askaboutphp.com/58/codeignite...rings.html
#6

[eluser]umbongo[/eluser]
OK i have changed to query strings and have the basic functionality working again.

Now I am having a little trouble sorting out the links from the page. For example, to sort by ID, the ID table header is linked with /controller/?sort_by=[$id] (where [$id] is the sort_by value.)

So that will sort by the ID column, but if something else is set then these will all be wiped out.

I could preserve the previous information by appending ?sort_by=[$id] to uri_string() (if it worked in this case - in practice it wipes out ? and after) but that would give me the problem of getting uris such as /controller/?sort_by=[$id]&sort;_by=[$id]

SO, is the only way to handle this to use a foreach loop checking if every parameter is set (and not equal to the perameter you are about to set) and then adding them into the uri when they are??
Is there a better way, as this seems massively convoluted???
#7

[eluser]pbreit[/eluser]
I'm not sure I understand what the problem would be. If someone clicks on the header link to sort, it should only contain one sort_by parameter.




Theme © iAndrew 2016 - Forum software by © MyBB