Tuesday, September 11, 2007

Sortable Lists

Is there a best practice way to order items in a list? By this - I'm not talking alphabetically or date ordered, but user ordered, the way the client wants things to show. More specifically and ideally, I would really like to see a best practice .NET way of doing it. Of course it also has to be easy to implement, and universal across any list of items... in any app we've built.

The way we have been doing it the last 6 years, is we would just add an extra field to the database (e.g. pageOrder), and have the user type in a number. The lower the number, the further it gets put down the list. (SELECT * fron tblPages ORDER BY pageOrder). Too bad if the same number gets entered for 2 records. Too bad if the records are only 1 number apart as well - it usually means the whole list needs re-arranging.

Another problem with the ordering approach is that it always gets forgotten off a spec. The client doesn't notice it until they need it, and when they need it - their argument is usually "I would have thought this an obvious inclusion". As well as this, for the developer it is always an afterthought and a chore to revisit the project to put in an ordering mechanism for 1 list. Then the vicious spiral starts where the client says - "well it's done for this list, but what about these other 5 lists?".

If we had a standard ordering mechanism that could be plugged into any list easily, that was user friendly, it would make me very happy. I am impressed with what I see over at scriptaculous, where their interactive sortable lists are very impressive, but I need it to plug into a ASP.NET datagrid, which doesn't seem quite possible yet.

No comments: