How do create a table that lets users arbitrarily change the order of rows?

How do create a table that lets users arbitrarily change the order of rows?

  
I can imagine tables to track things like open projects, bugs, user requests, etc.  How can I create a table that lets users either move a particular row up or down (changing the priority) or letting them change the priority of multiple rows in a table and then updating all of their priorities?

Thx.

Craig
Craig -

Well, the assumption is that they are sorted on some relevant items to begin with. Let's pretend that your "priority" field is an integer ranging from 1 to 10.

First, create an Action for "Move Up" and one called "Move Down" that accepts the ID type of the entity being displayed (say, "Ticket Identifer"). The "Move Up" action would do the following:

1. Call GetTicketForUpdate, passing in the ID that was taken.
2. Use Assign on the Priority attribute of the retrieved record, and assign: "If(GetTicketForUpdate.Record.Priority = 1, 1, GetTicketForUpdate.Record.Priority - 1".
3. Call UpdateTicket and pass in GetTicketForUpdate.Record
4. Perform a RefreshQuery on the query that the table is based on.
5. Do an AjaxRefresh of the container around the table.

"Move Down" looks the same, except for the If in the Assign from Step 2: "If(GetTicketForUpdate.Record.Priority = 10, 10, GetTicketForUpdate.Record.Priority + 1".

Add a column to the table, and in it, put text or images indicating "Move Up" and "Move Down". Link each one to the appropriate Action, passing in the table's "current" ID for the entity.

And you're done. :)

J.Ja