I’m planning on applying as a GSoC 2010 volunteer for WordPress. This is a working draft of my proposal.

Introduction

One of the key features missing from the list-type administration screens is the ability to view items sorted by a certain column. For example, on the posts screen, you should be able to view posts sorted by number of comments, in descending or ascending order.

Besides this, when you view the next page of items, the entire page is reloaded, when the list of items could be updated via AJAX.

So, my proposal has two parts:

Sorting by column

All list-type screens in WordPress are paginated. In other words, only a small subset of all the items are loaded at a time. This throws JavaScript sorting scripts like DataTable out the window. The sorting has to be done on the server-side.

This is not a big problem, since WordPress already has support for sorting most types of items.

In terms of UI, I won’t go with the regular clickable column headers approach because it has a 3-click cycle:

  1. sorted-ascending
  2. sorted descending
  3. unsorted

Unlike with JavaScript sorting, each click would be expensive, since it would require a new request to the server.

Instead, I plan on adding a dropdown to the Screen Options section, where the user could select the column to sort by. There would also be two radio buttons for the order: ASC / DESC. This way, the user can choose the sorting and the order in one request.

Either that, or add two buttons on each column, one for ASC and one for DESC sorting (hidden until the user hovers over that column).

AJAX Loading

After sorting is done, I can concentrate on speeding things up with AJAX. Whenever a user wants to see a different page of items, they will be fetched via an AJAX request and be inserted in place of the old items.

This should also work when: changing the sorting, changing the number of items per page.

Feedback

What do you think? Thoughts, ideas, suggestions etc. are very welcome. Use the comment form bellow.

Reactions (1)

  • [...] 2010 Filed in NewsWordPress 3.1-beta has been released into the wild.A huge thanks to Scribu for spending his summer time on a GSoC program and working on a major component upgrade for WordPress 3.1-beta. [...]

Comments (6)

  • Mac_Boy says:

    You have a good proposal.

    It is something that is very needed and valuable.

    We also need ability to add custom field column into those tables. Perhaps the API exists to do this already? If yes, then allow for sorting of these columns also.

    Thank you for all your contributions to WordPress and the Community. I always look for your insight when stuck on a problem.

    :-)

    • scribu says:

      Thanks for the comment. :)

      Yes, there already are filters which you can use to add or remove columns.

      And yes, I do plan to make it so that plugins can mark columns as “sortable”.

  • TobiasBg says:

    Hi scribu,

    really great to hear that you are applying for GSoC and I really hope that your proposal accepted! I would really like to see you work on this!

    Just a few remarks/questions:

    About that 3-click cycle: I’m a little confused about that one, because all JS libraries that I have seen so far (www.datatables.net, http://www.tablesorter.com, …) only switch between ASC and DESC, while unsorted is only the initial state. So, switching the sorting would also require just one server request.

    And to follow-up on the DataTables idea (that I mentioned on wp-hackers a few days ago): It has a nice API to have sorting/paging/filtering done server-side, with the results being fetched using AJAX (http://datatables.net/examples/server_side/server_side.html), so I can’t yet follow why you are throwing it “out of the window”. Can you explain?

    And finally, as you didn’t mention it explicitely: How about also making the search that we have on edit.php use AJAX (in DataTables it’s called “Filtering”)?

    Best wishes,
    Tobias

    • scribu says:

      About that 3-click cycle: I’m a little confused about that one, because all JS libraries that I have seen so far (www.datatables.net, http://www.tablesorter.com, …) only switch between ASC and DESC, while unsorted is only the initial state. So, switching the sorting would also require just one server request.

      You’re right, but you still couldn’t do a DESC sort directly. Also, there would need to be a button somewhere for going back to the unsorted state. This is important for screens with hierarchical items.

      And to follow-up on the DataTables idea (that I mentioned on wp-hackers a few days ago): It has a nice API to have sorting/paging/filtering done server-side, with the results being fetched using AJAX (http://datatables.net/examples/server_side/server_side.html), so I can’t yet follow why you are throwing it “out of the window”. Can you explain?

      I didn’t see that page. I was under the impression that you could only do the initial load through AJAX. So yeah, I guess DataTables isn’t out the window after all. :)

      And finally, as you didn’t mention it explicitely: How about also making the search that we have on edit.php use AJAX (in DataTables it’s called “Filtering”)?

      If I’m going to use DataTables, sure.

      Thanks for the insights.

      • TobiasBg says:

        Hi scribu,

        thanks for the clarification on the 3-click cycle. That makes sense now :-)

        Even you decide to not use DataTables, the filtering/search would be a nice thing to be AJAXified. Maybe not a must to do it realtime like DataTables does it, but as the search code should be there, it would probably be pretty similar to a regular AJAX request when paging through the list.

        Best wishes,
        Tobias

  • jeromy says:

    you got my vote, I’d LOVE to see this

Respond / add a comment


Subscribe without commenting