Friday, January 16, 2009

Creating Data Forms in SharePoint Designer, Part 4: Sorting and Grouping

In the previous post I showed you how to add a Multiple Item View Data Form Web Part to your SharePoint page. Next, I will show you how to add sorting and grouping to it to make it more user-friendly. I have added some more questions to the Frequently Asked Questions list. The list currently looks like this:

I will open the web page (default.aspx) in SharePoint Designer and then click on the DataFormWebPart so that it is highlighted. You will notice the expansion arrow appear to the right:

When I click on the arrow, a menu appears for Common Data View Tasks:

I select the Sort and Group task and I am presented with the Sort and Group options window. Because I want to group by Category, I must add it first to my sort order list and then select the checkbox that reads “Show group header” with the default option of “Expand group by default”. The options now look like this:

When I click OK, I return to the Common Data View Tasks menu. From here I can set additional options such as how many items to display per page and other formatting options. I will leave everything else alone for now and save my web page. When I preview it in my browser it now looks like this:

In a future post I will demonstrate how to use the Data Form Web Part with a SQL Server database instead of a SharePoint list. I will also demonstrate how to use the Data Form Web Part to collect information from a user. Is there something in particular you would like to see demonstrated? Leave a comment and let me know.


Unknown said...

I am new to using SPD and customizing Sharepoint, I really like this for the FAQ. What I have not been able to figure out how do is to Group by the Category, and when it is expanded, show just the questions until a question is clicked? Is that possible?

When I go to the Available Fields in the SOrt and Group, the Question Field does not show up.

Rob Wilson, MCT, SharePoint MCTS/MCITP/MCPD said...


That is a great question and an excellent idea. The reason the question field does not show up is because it is defined as Multiple Lines of Text. If you can live with the question being 255 characters or less, change the field type to Single Line of Text and you can accomplish what you are trying to do.

Thanks for reading!

Rob Wilson