Andreas Lindahl

Hi

We're developing a MOSS WCM site. We store list items in a list and then use the API to fetch these items, displaying them on a Publishing page. Is it possible to change the sort order of the items I don't want to sort on a specific column, instead the content editor should have the option to change the sort order of the items to his/her liking, sort of like how pages and sites can be sorted by going to the "Modify navigation" page.


Re: SharePoint - Development and Programming Sorting list items

AC [MVP MOSS]

You'll want to do this in the CAML query you use to retrieve the results. WIthin the CAML you can specify the ordering, just like you do with TSQL when querying a DB. Another option is to pull the data back using the SPList.Items.GetDataTable() method which returns an ADO.NET DataTable which you can use the sorting techniques you're used to.

Check this paper for some info on data access options: http://go.microsoft.com/fwlink/ LinkId=95450&clcid=0x409






Re: SharePoint - Development and Programming Sorting list items

Andreas Lindahl

Hi

But when using a CAML query it's only possible to sort the items by a specified column, or several columns, right

The idea is to make it possible for our content editors to sort the items in the list in any way they want, i.e. not just by a column. Is it possible to change the order of list items in the same way that sites and pages can be ordered by going to Site Actions > Site Settings > Modify Navigation, i.e. by moving items up or down in the list Or am I stuck with using a CAML query, and sort on a column

Oh, and thanks for the link to the paper, by the way. It included some really useful information.





Re: SharePoint - Development and Programming Sorting list items

AC [MVP MOSS]

You'd have to implement this type of functionality yourself, just like they did in the Navigation admin page. It really is no different than working with a DB in pure ASP2 sites. You can get the data, but if you want to manually sort it by moving thinggs around, you'll have to implement that type of functionality. For instance, it sounds like you want to have an extra field in the list of SortOrder and you would have to maintain this from your custom code to implement the custom sorting.

To your question, yes when you use CAML to do sorting, you can only sort by column and the direction.