Compartilhar via


Data View formatting: controlling the presentation of your data using 'Format Item As...'

Beyond look and feel, there is lots of other formatting support in the Data View. One of the most important is that you can easily change the way the Data View interprets data for presentation, i.e. for fields such as dates, hyperlinks, rich text, numbers, etc, you can tell the Data View exactly how you would like that data represented on the page. For example, let's say you have a number field in your data source - in your view, you might want that number formatted as British Pound currency. Using the 'Format Item As...' feature, you can easily do this.

a quick example:
In this Data View, I have a 'created date' column. The data itself stores both the date and time for each record. However, in my view, I just want the date to show up...

I can easily make this presentation change by right-clicking any row Created column, and choosing the 'Format Item as -> Date & Time...' menu.

Clicking 'Format as Date & Time' will bring up a nifty little dialog we have which gives you the option to hide either the date or time. You can also change how either the date or time is represented. For example, you can change the date to be shown with the year first. For our little demo, we'll just uncheck 'show time' ...

Press ok and voila! As you can see, the time is now gone from the view.

In addition to being accessible via the field's context menu, you can also get at it from the top-level 'Data' menu. The feature works against all kinds of different field types - it's worth messing around with :).

Coming up, I'll dig a little into how the data view works (hint: it's built on standard XSLT technology) and how you can use that knowledge to your advantage!

Comments