By nadongtae on
I want to make a table which can be sorted if i click on headers . However,this sorting must be effect to all pages. For example, my database has 3 fields : id,name,date . I list it on many pages. When i click on header Id. It will show the sorted table base on Id even though i move to other pages.
How can i do it ?
Can anyone give me a simple example to do that ? Thanks for all your supporting.
Comments
Do you already have this
Do you already have this table somewhere? If yes, perhaps the best you just create a PHP function...
Otherwise, that's the Drupal way:
Use CCK (http://drupal.org/project/cck) to build the "table". In other words: create a content type and insert the fields: "id" and "date". Make sure to have no body in the content type.
Then install Views (http://drupal.org/project/views) and create a view that shows only that very type using a "Table View".
Regards,
José San Martin
José San Martin
http://www.chuva-inc.com/
Sorry,but can you give me an example
Thanks for your help but can you give me more details ? It will be better if you give me an obvious example.
Sorting with theme_table
Here is a function I created in a recent project. This function will output a table with sortable columns and paging navigation links. Sorting will be maintained across all pages.
--
Nathan Rambeck
Rambeck Group
--
Nathan Rambeck
Thank you so much for this.
I'd been trying to come up with the same result and this was exactly the kick-start I needed.
me too ... it was all over in
me too ... it was all over in minutes thanks to the wonderful nrambeck help
i can't believe i have been exploding rows the old way while this was under my nose with sort order and pager to boot!
thanks nrambeck
Just want to share a little
Just want to share a little hard learned experience here. In this example, the sql query doesn't have a "where" clause. If you have a "where" condition in your sql query, you may see undesired result.
In my case, I should have only one page, but pager_query() counted I have 6 pages, therefore it displayed many page markers below the table, (something like (<< first, 1, 2, 3, 4, 5, 6,... next, last >>), very annoying.
The problem is pager_query() may not count the number of page correctly if you have a where clause in your query. If you do, then you may need to provide a counter_query.
Check pager_query() API doc for more details. I scratched my head for a few hours to find out the problem.
Thank you very much! This
Thank you very much! This code is exactly what I needed, and it was very easy to understand!
Sorting table with data from two sql request ?
How I can make sortable table with data from two request?
Example:
Sorting table with data from two sql request ?
Did you finally get this, W32? I'm interested in sorting the table using subquery data...
Default sort Ascending Order
I just thought I would mention that
'sort'=>'asc'only appears to work when asc is in lower case, not UPPER case.
subscribing
subscribing
http://SocialNicheGuru.com
Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.
Drupal 7 example
From berdir:
--
Morris Animal Foundation