Important notice

Please note that this blog is discontinued here. All the posts are also coppied to my new blog at
Important: Due to large amount of comment spam further commenting has been disabled here. If you wish to send me a comment, plase look up the same post on my new blog and leave comment there. Thanks!


Reordering items in data view

A links list in SharePoint has an interesting functionality - to change the order of items.

I've tried and this functionality can be applied to all the lists and used in a data view. Let's go in order.

To reorder the list go to _layouts/reorder.aspx?list={list_guid} in the same site. If you don't know the list guid, go to list settings and replace listedit.aspx with reorder.aspx. You'll go to the interface to reorder items in that list:

The change will not be visible in SharePoint's AllItems.aspx page.

To sort items in the data view according to ordering you just made:

With data view inserted to the page the first thing we need to do is add the order field to the data view fields. To do this click the list name in the task pane Data Source Details

Next click button Fields, find and select Order in the left column and click Add.

Click OK to confirm the changes and close the Data Source Properties dialog by clicking OK again. Now you select data view Sorting (in Common Data View Tasks select Sort and Group) and you can choose Order. If you can't find Order in the dialog box, click the last option (Add Sort Expression) and click Add.

In the next dialog box, you can select Order from the fields.

Now confirm all the selections by clicking OK to close all dialog boxes.

That's not all. Now it's sorted according to order number, but the XSLT is taking this like a text. So we have to fix this. In source code, find <xsl:sort select="@Order" and add a data-type="number" parameter to it.

That's it. Now you have items sorted according to the ordering you've made.

What I usually like to add to the data view is a link to reorder items. Just add a footer and in the footer add a hyperlink to the reorder page (the one mentioned at the beginning).

Oznake ponudnika Technorati: ,,


line47 said...

When I try to set the order in the data view it always reverts back to the original Data source information.

Any ideas why this would happen?

David Kreth Allen said...

An alternate way to achieve ordering is to add a custom sort order text column. Then you can use this sort order in various views. As a text column, you can easily insert items between other items by using a series of decimals (1.5 will sort after 1 and before 2. 1.5.3 will sort after 1.5, etc...) the best thing about this approach is that you can edit the list in datasheet view and drag the numbers down as if you were in Excel, and it will intelligently renumber them to clean up these insertions.

Anonymous said...


thanks for this article is really useful.

do you know if is any want on filter the items to ordered maybe passing a specific view parameter on the url ?