Displaying the Document Icon in a CrossList SharePoint 2010 DFWP

Once again, I’m finding that the DataForm Web Part (DFWP) acts slightly differently when you’re using it as a roll-up. And, once again, I’m finding great info out there on Marc Anderson’s blog about what I want to do. But, once again, it needs a slight tweak to work with a roll up.

So, if you want to include the document icon in a DFWP when you’re using it in CrossList mode with recursion through sub-sites, instead of this:

<img src="/_layouts/images/{ddwrt:MapToIcon('', ddwrt:GetFileExtension(string(@FileLeafRef)))}" alt="Type" />

You’ll need this:

<img src="/_layouts/images/{ddwrt:MapToIcon('', string(@DocIcon))}" alt="Type" />

DocIcon will need to be included in your FieldRef section of your SelectCommand:

<FieldRef Name="DocIcon"/>

Advertisements
Next Post
Leave a comment

5 Comments

  1. Interesting. I could see this not working:
    ddwrt:GetFileExtension(string(@FileLeafRef))
    but you should be able to substring out the filename, maybe this?
    GetFileExtension(string(substring-after(@FileLeafRef, ';#')))

    M.

    Reply
    • Either work – but if SP is already passing back just the extension in @DocIcon, isn’t it less processing to just use that as opposed to doing XSLT string functions?

      Reply
  2. Fair, but if you don’t need to pull back the @DocIcon column in the query, then it *may* be more efficient. More than one way to skin the cat, for sure.

    M.

    Reply
    • I’m new-ish to SharePoint and still figuring out what pieces parts do exactly what behind the scenes, so I’m definitely not pretending to know which is the best approach. But, in general I have always tried to let the database do what it can. Of course, I don’t know if @DocIcon is the database doing something or the in-between code doing something.

      Reply
      • If you’re using DataSourceMode=”CrossList”, then you have to specify the columns you actually want returned. Because of this, I believe that any columns not requested won’t be pulled out of the DB. So, potentially a performance difference if there are a lot of items, but undoubtedly not much of one for a three character extension.

        M.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: