Filter, sort, or group a Data View in the browser

You can add a toolbar to a Data View so that users can filter, sort, or group data in the Data View by using the toolbar in the browser.

You can also turn on filtering and sorting on column headers in a Data View, so that users can filter or sort the data by clicking the column headers, just like a list view.

These options are mutually exclusive: You can add the toolbar or use the column headers but not both. In addition, you can add the toolbar to a Data View that uses any layout, but the column headers can be added only to a Data View that uses the Basic Table layout. For more information about layouts, see the article Change the layout of a Data View.

To create the sample data and Data View that are used in the following examples, or to learn more about Data Views, see the article Create a Data View.

In this article

Add or remove a toolbar that filters, sorts, or groups data

Add or remove filtering and sorting on column headers

Add or remove a toolbar that filters, sorts, or groups data

When you use the toolbar to filter a Data View in the browser, the filtering affects only the presentation of the data. The filtering does not happen at either the source level of the XSLT level. For more information about filtering a Data View, see the article Filter data in a Data View.

The following illustration shows the toolbar added to a Data View on a new .aspx page.

Toolbar added to a Data View

If you attach Default.master to the page that contains the Data View and toolbar, some built-in styles from Core.css get applied, as shown in the following illustration.

Toolbar added to a Data View on a page that has default.master applied to it

Note: If you add or remove fields to a Data View after you add the toolbar, the toolbar does not get automatically updated with the new field set. To update the fields that appear in the drop-down menus on the toolbar, you must remove the toolbar and then add it again.

To add the toolbar to a Data View:

  1. Open the page that contains the Data View.

  2. Right-click the Data View, and then click Show Common Control Tasks.

    Tip: You can also click the Data View, and then click the arrow Button image in the upper-right corner to show the Common Data View Tasks list. Click the arrow again to hide the list.

  3. Click Data View Properties.

    The Data View Properties dialog box opens.

    Filter, Sort, and Group options highlighted in Data View Properties dialog box

  4. On the General tab, do one of the following:

    • To add the toolbar, select the Show toolbar with options for check box, and then select the check boxes below that you want.

    • To remove the toolbar, clear the Show toolbar with options for check box.

  5. Click OK.

Top of Page

Add or remove filtering and sorting on column headers

Another option provides the mechanism of sorting and filtering by using the column headers in the table. Here you can sort and filter data by just selecting the appropriate option in the drop-down of the column header. When you use this option, certain CSS styles (named .ms-vh, .ms-vb, and .ms-alternating) are applied and the Data View has a different look and feel. The following picture shows how a Data View appears when you enable sorting and filtering on column headers.

Drop-down menu on column header in a Data View

Note: If you add or remove fields to a Data View after you turn on sorting and filtering on column headers, the toolbar does not get automatically updated with the new field set. To update the fields that appear in the drop-down menus on the column headers, you must remove the toolbar and then add it again.

  1. Open the page that contains the Data View.

  2. Right-click the Data View, and then click Show Common Control Tasks.

    Tip: You can also click the Data View, and then click the arrow Button image in the upper-right corner to show the Common Data View Tasks list. Click the arrow again to hide the list.

  3. Click Data View Properties.

    The Data View Properties dialog box opens.

    Sorting and filtering on column headers option highlighted in Data View Properties dialog box

  4. On the General tab, do one of the following:

    • To turn on sorting and filtering, select the Enable sorting and filtering on column headers (basic table layout only) check box.

    • To turn off sorting and filtering, clear the Enable sorting and filtering on column headers (basic table layout only) check box.

      Note: 

    • When you turn off sorting and filtering on column headers by clearing the check box, the CSS styles are still applied to the Data View. You can remove these styles manually — for more information, see the article Remove or delete a style.

    • Sorting and filtering on column headers works only if the Data View uses the Basic Table layout. To verify which layout your Data View uses, click the Layout tab.

  5. Click OK.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×