Thursday, February 19, 2009

People column and the dataview webpart

A quick one for my first Blogspot blog!

So, I've been playing around allot with the dataview webpart lately - it has so many uses.

The most obvious use is to bring any document library to any page within the same site collection, and in doing so, maintain most of the flexibility and ease of use of the normal document library webparts. Obvisouly as a consultant / configuration guy there's a little more to it, because you need to fiddle around in SharePoint designer with the XSL, but it's fairly straight forward. The other use, which is even more powerful is to use it as a quick and easy way to get some simple business intelligence and live reporting onto a SharePoint page.

Over the coming weeks, I hope to get down a number of "how tos" and "gotchas" for the above 2 scenarios.

My first one is the way a dataview handels a "person or group" column from a list of library.

The first thing to remember is that when you select a person from a person or group column (or indeed the automatically assigned ones such as Modified by and Created by), SharePoint likes to keep a whole bunch of extra data. This data is used to give the name a link to their profile in SharePoint, pressence awareness with communicator etc. etc. BUT it gets in the way when you're trying to play with the data in a dataview...

Firstly, when you display your dataview, you might get a column full of text like this;

















Why is this? Well, this is obviously text with mark-up (you can see the person's name in there, a link to their profile, the image indicating their presence and a bunch of other lovely stuff.




Making your dataview actually show you the name with presence is pretty simple, you can change the field type to "rich text" which will parse the mark-up;













Or, you can change it in code - simply go to the for that field, and add disable-output-escaping="yes".


Easy peasy.



Next post I'll go through doing a look-up on these field types. How can we compair someones name against this field with all the extra guff it contains?


No comments:

Post a Comment