{"id":1453,"date":"2011-12-30T17:04:44","date_gmt":"2011-12-30T17:04:44","guid":{"rendered":"http:\/\/www.obieta.com\/?p=1453"},"modified":"2011-12-30T17:04:44","modified_gmt":"2011-12-30T17:04:44","slug":"modifying-the-sharepoint-2010-preview-pane-view-style","status":"publish","type":"post","link":"http:\/\/obieta.com\/?p=1453","title":{"rendered":"Modifying the SharePoint 2010 Preview Pane View Style"},"content":{"rendered":"<p>Out of the box, SharePoint 2010 offers several styles that can be selected when creating a view of a list or library. One really useful style is the Preview Pane. If you have a list with a lot of columns, the Preview Pane style is great for creating a vertical view of the data, avoiding the dreaded horizontal scroll. If you\u2019re not familiar with the Preview Pane, Microsoft has a quick <a href=\"http:\/\/office.microsoft.com\/en-ca\/sharepoint-server-help\/sharepoint-lists-vii-handy-tips-and-tricks-RZ102425640.aspx?section=11\">screen cast<\/a> that shows how to use it.<\/p>\n<p>Unfortunately, out of the box, there\u2019s no way to identify which column should be used in the pick list \u2013 that list of items on the left side of the preview pane. It defaults to the title column, and there\u2019s no way in the web-based tools to modify that. So, what happens if for some reason you\u2019re not using the title column in the intended manner? Well, you end up with something like this:<\/p>\n<div id=\"attachment_161\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/ootb.png\"><img loading=\"lazy\" title=\"A Not Very Functional Preview Pane View\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/ootb.png?w=600&amp;h=310\" alt=\"A Not Very Functional Preview Pane View\" width=\"600\" height=\"310\" \/><\/a><\/p>\n<p>A Not Very Functional Preview Pane View<\/p>\n<\/div>\n<p>Not so great, right? If you Google around for a solution, you\u2019ll find options such as <a href=\"http:\/\/www.endusersharepoint.com\/STP\/viewtopic.php?f=10&amp;t=2190\">using a workflow<\/a> to update the title column with the data you want when an item is added or using a <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-us\/sharepointdevelopment\/thread\/f1afd1a2-1c7a-4dc6-9c17-730c6c83fa44\">CAML editor tool<\/a>. Hm\u2026. No thanks.<\/p>\n<p>Turns out that you can make it work with a little help from SharePoint Designer. Fire up SharePoint Designer 2010. Load your site. Navigate to your list. In the Views module, click the preview pane view that you created. (If you haven\u2019t created one, watch that <a href=\"http:\/\/office.microsoft.com\/en-ca\/sharepoint-server-help\/sharepoint-lists-vii-handy-tips-and-tricks-RZ102425640.aspx?section=11\">screen cast<\/a> and create one first.)<\/p>\n<div id=\"attachment_162\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/editpreviewpane.png\"><img loading=\"lazy\" title=\"Click the Preview Pane View to edit it\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/editpreviewpane.png?w=600&amp;h=495\" alt=\"Click the Preview Pane View to edit it\" width=\"600\" height=\"495\" \/><\/a><\/p>\n<p>Click the Preview Pane View to edit it<\/p>\n<\/div>\n<p>Now that you\u2019re in edit mode for the Preview Pane style, do any of the typical tweaks you might do on any view \u2013 change the sort order, the paging, add or remove columns. Do everything you might want to do using the Ribbon options before we get to this next part. It makes life easier.<\/p>\n<p>Now for the fun stuff.<\/p>\n<p>Find either the title or the words \u201c(no title)\u201d in the left column. Highlight either the title in a row of data or the \u201c(no title)\u201d words. Right click, and select \u201cEdit Formula.\u201d<\/p>\n<div id=\"attachment_164\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/formattitle1.png\"><img loading=\"lazy\" title=\"Highlight the words to replace and select &quot;Edit Formula&quot;\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/formattitle1.png?w=600&amp;h=683\" alt=\"Highlight the words to replace and select &quot;Edit Formula&quot;\" width=\"600\" height=\"683\" \/><\/a><\/p>\n<p>Highlight the words to replace and select &#8220;Edit Formula&#8221;<\/p>\n<\/div>\n<p>A pop-up window will open where you can select another column of data, enter static text, or use any number of formulas to generate the text you want to use. I concatenated two columns.<\/p>\n<div id=\"attachment_163\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/formattitle.png\"><img loading=\"lazy\" title=\"Using a formula to concatenate columns\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/formattitle.png?w=600&amp;h=612\" alt=\"Using a formula to concatenate columns\" width=\"600\" height=\"612\" \/><\/a><\/p>\n<p>Using a formula to concatenate columns<\/p>\n<\/div>\n<p>If you have some rows of data with titles and some without, you\u2019ll need to repeat this process for both types of columns.<\/p>\n<p>So, what\u2019s happening behind the scenes is that a new XSLT template is being added to code view. It\u2019s called the \u201cLinkTitleValue.LinkTitle\u201d template, and it determines what data is being used for the link to the item. The template looks like this:<br \/><code><br \/>&lt; xsl:template name=\"LinkTitleValue.LinkTitle\" ddwrt:dvt_mode=\"body\" ddwrt:ghost=\"\" xmlns:ddwrt2=\"urn:frontpage:internal\"&gt;<br \/>&lt; xsl:param name=\"thisNode\" select=\".\"\/&gt;<br \/>&lt; xsl:param name=\"ShowAccessibleIcon\" select=\"0\"\/&gt;<br \/>&lt; xsl:variable name=\"titlevalue\" select=\"$thisNode\/@Title\"\/&gt;<br \/>&lt; xsl:choose&gt;<br \/>&lt; xsl:when test=\"$titlevalue=''\"&gt;<br \/>&lt; xsl:value-of select=\"concat($thisNode\/@Chapter_x0020_Name, ' - ', $thisNode\/@EIN)\"\/&gt;<br \/>&lt; \/xsl:when&gt;<br \/>&lt; xsl:otherwise&gt;<br \/>&lt; xsl:choose&gt;<br \/>&lt; xsl:when test=\"$HasTitleField\"&gt;<br \/>&lt; xsl:value-of select=\"concat($thisNode\/@Chapter_x0020_Name, ' - ', $thisNode\/@EIN)\" \/&gt;<br \/>&lt; \/xsl:when&gt;<br \/>&lt; xsl:otherwise&gt;<br \/>&lt; xsl:value-of select=\"$titlevalue\" \/&gt;<br \/>&lt; \/xsl:otherwise&gt;<br \/>&lt; \/xsl:choose&gt;<br \/>&lt; \/xsl:otherwise&gt;<br \/>&lt; \/xsl:choose&gt;<br \/>&lt; xsl:choose&gt;<br \/>&lt; xsl:when test=\"$ShowAccessibleIcon\"&gt;<br \/>&lt; img src=\"\/_layouts\/images\/blank.gif\" border=\"0\" width=\"1\" height=\"1\" alt=\"{$idPresEnabled}\" \/&gt;<br \/>&lt; \/xsl:when&gt;<br \/>&lt; xsl:otherwise&gt;&lt;\/xsl:otherwise&gt;<br \/>&lt; \/xsl:choose&gt;<br \/>&lt; \/xsl:template&gt;<br \/><\/code><br \/>Save your file and test it. Looks great, right?<\/p>\n<div id=\"attachment_165\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/goodversion.png\"><img loading=\"lazy\" title=\"Title Successfully Replaced\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/goodversion.png?w=600&amp;h=450\" alt=\"Title Successfully Replaced\" width=\"600\" height=\"450\" \/><\/a><\/p>\n<p>Title Successfully Replaced<\/p>\n<\/div>\n<p>You have now successfully replaced your title with your preferred information and it\u2019s linked to the item. It also has an ECB menu attached to the item.<\/p>\n<p>What happens if we use the ECB menu to view or edit the item? Oops! The Javascript gets confused and it drops out the text we just spent our time putting in there!<\/p>\n<div id=\"attachment_166\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/ecbmenuerror.png\"><img loading=\"lazy\" title=\"Oops! Where'd our text go?\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/ecbmenuerror.png?w=600&amp;h=450\" alt=\"Oops! Where'd our text go?\" width=\"600\" height=\"450\" \/><\/a><\/p>\n<p>Oops! Where&#8217;d our text go?<\/p>\n<\/div>\n<p>I haven\u2019t dug into why this is happening, and I\u2019m sure someone else will do that. (Leave a comment if you figure it out!) But, I do have a workaround. One more step. I find this step easier to do back in the browser. So, save and close SharePoint Designer. Fire up notepad and type the following:<br \/><code><br \/>&lt; style type=\"text\/css\"&gt;<\/code><\/p>\n<p>.s4-ctx {<br \/>display:none;<br \/>}<\/p>\n<p>&lt;\/style&gt;<\/p>\n<p>Save it as a text file and upload it to your site. Make note of the location. (Right click and \u201ccopy shortcut.\u201d) (I used the \u201csite assets\u201d library.)<\/p>\n<p>Navigate to your view. Select Site Actions -&gt; Edit Page. Add a Content Editor Web Part and edit the web part to add a Content Link. Paste the shortcut and click \u201cOk.\u201d<\/p>\n<div id=\"attachment_167\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/contenteditor.png\"><img loading=\"lazy\" title=\"Link to your text file from the content editor webpart.\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/contenteditor.png?w=600&amp;h=538\" alt=\"Link to your text file from the content editor webpart.\" width=\"600\" height=\"538\" \/><\/a><\/p>\n<p>Link to your text file from the content editor webpart.<\/p>\n<\/div>\n<p>Save your file. Your \u201ctitle\u201d pane will now have the data you want, minus the ECB menu. Hovering over the item will load it in the preview pane. Clicking it will load the pop-up window for viewing or editing the content. One caveat, and Microsoft insists it\u2019s a \u201cfeature \u2013 not a bug,\u201d is that you\u2019ve now lost your view menu in the breadcrumbs. (Glyn Clough provides <a href=\"http:\/\/www.glynblogs.com\/2011\/02\/list-view-selector-missing-with-multiple-web-parts-in-sharepoint-2010.html\">more information<\/a> about this issue. And Pentalogic has a <a href=\"http:\/\/blog.pentalogic.net\/2011\/03\/disappearing-view-selector-menu-sharepoint-2010\/\">free solution<\/a> that fixes the issue on all pages, but may be a bit \u201cnuclear,\u201d as they put it.)<\/p>\n<div id=\"attachment_168\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/noviewmenu.png\"><img loading=\"lazy\" title=\"The View Menu disappears on view pages that have been edited.\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/noviewmenu.png?w=600&amp;h=390\" alt=\"The View Menu disappears on view pages that have been edited.\" width=\"600\" height=\"390\" \/><\/a><\/p>\n<p>The View Menu disappears on view pages that have been edited.<\/p>\n<\/div>\n<p>The workaround for that is to edit the page in SharePoint Designer to add your custom css. However, this customizes the page. You\u2019ll have to choose whether you\u2019d rather deal with customized pages or an alteration of the the UI. If you want to customize the page and retain the breadcrumbs, remove the Content Editor Webpart and save your page. Fire up SharePoint Designer again. Navigate to your list. Right click on your Preview Pane view and select \u201cEdit File in Advanced Mode.\u201d<\/p>\n<div id=\"attachment_173\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/editadvanced.png\"><img loading=\"lazy\" title=\"Edit File in Advanced Mode\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/editadvanced.png?w=600&amp;h=420\" alt=\"Edit File in Advanced Mode\" width=\"600\" height=\"420\" \/><\/a><\/p>\n<p>Edit File in Advanced Mode<\/p>\n<\/div>\n<p><em>Note: If you do not have the Edit File in Advanced Mode option, it is because your site collection or farm administrator has restricted the use of SharePoint Designer in your environment.<\/em><\/p>\n<p>Once your view loads in advanced mode, switch to code view and search for \u201cPlaceHolderAdditionalPageHead.\u201d Add the CSS we had previously added via the Content Editor Webpart to that tag, like so:<\/p>\n<div id=\"attachment_174\"><a href=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/addcss.png\"><img loading=\"lazy\" title=\"Add CSS Via SharePoint Designer\" src=\"http:\/\/deannaschneider.files.wordpress.com\/2011\/10\/addcss.png?w=600&amp;h=423\" alt=\"Add CSS Via SharePoint Designer\" width=\"600\" height=\"423\" \/><\/a><\/p>\n<p>Add CSS Via SharePoint Designer<\/p>\n<\/div>\n<p>Save your file. Voila \u2013 you now have customized title pane with no ECB menu and have retained the view selector breadcrumb.<\/p>\n<p>The other major advantage of using this method versus the Content Editor Webpart is that the CSS will render in the head of the page, where it belongs. However, if you do choose to use this approach, make sure you are tracking what pages you are customizing so that when it comes time to upgrade you\u2019ll know which files need to be double-checked.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Out of the box, SharePoint 2010 offers several styles that can be selected when creating a view of a list or library. One really useful style is the Preview Pane. If you have a list with a lot of columns, the Preview Pane style is great for creating a vertical view of the data, avoiding [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,1],"tags":[],"_links":{"self":[{"href":"http:\/\/obieta.com\/index.php?rest_route=\/wp\/v2\/posts\/1453"}],"collection":[{"href":"http:\/\/obieta.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/obieta.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/obieta.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/obieta.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1453"}],"version-history":[{"count":0,"href":"http:\/\/obieta.com\/index.php?rest_route=\/wp\/v2\/posts\/1453\/revisions"}],"wp:attachment":[{"href":"http:\/\/obieta.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/obieta.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1453"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/obieta.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}