Showing posts with label SharePoint Designer. Show all posts
Showing posts with label SharePoint Designer. Show all posts

3/17/2013

Freezing the Title Row of a SharePoint 2010 List or Library

 

SharePoint 2010 lists and libraries do not have scrollbars. The pages do, but when you scroll down a long list you will find that the column headings scroll off of the top of the page. The little project below is a quick and dirty little project to add scrollbars to a list and lock the column titles in place.

Before scrolling: (click the image for a larger version)

image

After scrolling (headings have scrolled off of the top):

image

After the fix below:

image

Bonus! Notice that not only are the column headings always displayed, but so is the "Add new item link" at the bottom!

Before you continue…

  • This is a work in progress and presented as starting point for your own experiments!
  • This has only been tested in SharePoint 2010
  • It can be made to work with 2013, but there's a few extra steps that I'll need to document
  • This works with View pages… it needs more work before being used with views displayed in web parts
  • There's some excess white space at the top of the list.
  • This does not work with the following view options (and probably a few more):
    • Grouping
    • The Content Editor Web Part as adding it breaks the default view selection behavior (You must use SharePoint Designer)
  • There is a flaw with FireFox and possibly other browsers:
    • The heading row may be listed twice

 

If you are OK with the above, then give it a try!

Steps:

  1. If you don't want to customize the default "All Items" (allitems.aspx) view then create a new Standard view
  2. You may want to customize your view and set the item limit to a number larger than the default of 30. Do not exceed 5000. (A SharePoint restriction)
  3. Open the site in SharePoint Designer
  4. Click Lists and Libraries and click your list
  5. Click the view you want to customize
  6. Click the Advanced Mode button in the Home tab of the ribbon
  7. In the Code pane scroll down and find "</WebPartPages:WebPartZone>" – you will add your code between that tag and the "</asp:Content>" tag
  8. Copy the code from below and paste between the two tags listed above
  9. Edit the following line and replace Bikes with the name of your list
        var SummaryName = "Bikes "
     
    Note: View your list page, use the browser's View Source feature and search for "summary=". Copy what follows including any spaces. If your list is named Bikes and has no description defined then you will find "Bikes ".  (note the space at the end) If your list has a description then you may find something like "Bikes This is a list of bikes for sale."  (note the exact use of spaces and the possible presence of a period or other punctuation)

    Another example: The default Shared Documents library has this summary name: "Shared Documents Share a document with the team by adding it to this document library."
     
  10. In the <style> section adjust the height of the scrolling area of your list – you may need some trail and error here
    #TTNlist
    {
      height:200px;
      overflow-y:scroll !important;
      overflow-x     :auto
    }
  11. Save your changes and test your view

If it does not work:

Check your SummaryName! It has to be exactly what's found in the view page's HTML.

Try a delayed run of the script…

  Comment out this line by adding two slashes at the beginning:
    //or call the function immediately
    TTNListScroll();         <—this line

  And uncomment the spBodyOnLoadFunctionNames line:
    // update the list after the page has loaded
    //_spBodyOnLoadFunctionNames.push("TTNListScroll");

 

 

The code:

<script>
 
function TTNListScroll()
{
  // Scrolling list code from TechTrainingNotes.blogspot.com
  // Edit the next line with your list's summary name
  var SummaryName = "Bikes 2 ";
 
  var TTNmyTable;    
  var TTNListDiv = document.createElement('div'); 
  var TTNHeadingDiv = document.createElement('div');
 
  var tables = document.getElementsByTagName("TABLE");
  for (var i=0;i<tables.length;i++)
  {
    if ( tables[i].summary == SummaryName )
    {
      TTNmyTable = tables[i];
      break;
    }
  }
 
  if(TTNmyTable == undefined)
  {  
    //
    // Table not found!
    // you may want to comment out the next line after testing
       alert("table '" + SummaryName + "' not found");
    //
    return;
  }
 
  // make a copy of the table for the heading area
  TTNHeadingDiv.appendChild(TTNmyTable.cloneNode(true)); 
  TTNHeadingDiv.id="TTNheading";
  TTNListDiv.appendChild(TTNmyTable.cloneNode(true)); 
  TTNListDiv.id="TTNlist";
  TTNListDiv.width="100%";
 
  // udpate the page
  var TTNnode = TTNmyTable.parentNode
  TTNnode.replaceChild(TTNHeadingDiv, TTNmyTable);
  TTNnode.appendChild(TTNListDiv);
 
  // hide the heading row of the main list
  TTNListDiv.childNodes[0].rows[0].style.visibility='hidden';
  
  // make the DIV for the heading the same width as the main list
  TTNHeadingDiv.childNodes[0].style.width = TTNListDiv.childNodes[0].offsetWidth 
}
 
// update the list after the page has loaded
//_spBodyOnLoadFunctionNames.push("TTNListScroll"); 
 
//or call the function immediately
TTNListScroll();
 
</script>
 
<style type="text/css">
 
#TTNheading
{
  height:28px;
  overflow:hidden;
}
 
#TTNlist
{
  height:200px;
  overflow-y:scroll !important;
  overflow-x     :auto
}
 
</style>

 

 

.

12/22/2012

Weird problem with SharePoint Designer workflows and Office 365

 

I wanted to add a quick little workflow to a SharePoint Online / Office 365 (2010) site using SharePoint Designer 2010. When adding the workflow all I got was a blank screen.

My steps:

  • Open SPD 2010 and open the Online (2010) site
  • Click Workflows, click new List Workflow, select my list, enter a title and description, click OK
  • and…  nothing… no workflow editor, no error message, just a blank workflow list

                           image

Note that this was a SharePoint Online 2010 site, not a 2013 site.

The fix?

Create the workflow using SharePoint Designer 2013! SPD2013 can create both 2010 and 2013 style workflows, but when used with a 2010 site it can only create 2010 style workflows.

Here's the KB:

You have problems with workflows or receive errors in SharePoint Designer 2010
http://support.microsoft.com/kb/2794961

.

10/14/2012

SharePoint - Filtering a View by Group Membership

 

I use this blog to both share things I have discovered about SharePoint and as a place to store "stuff" so I can find it later. Kind of like personal notes…  The following is not an original discovery, just a step by step set of notes for a solution from tips I have found elsewhere. The core XML that led to this article where found here:
http://spboom.com/sharepoint-development/how-to-filter-sharepoint-list-by-membership-in-sharepoint-group/
and here:
http://sympmarc.com/2010/06/16/caml-filter-for-current-group-membership/

Filtering a View by Group Membership

There are a number of possible solutions to this problem:

 

Filtering a View by Group Membership

Notes:

  • This is not security! Other views of the list will still display all of the items.
  • The XML query can be much, much more complicated with the addition of ANDs and ORs. For example, you might add an OR section to always show all items for site owners.
  • The following works on a view (XsltListViewWebPart), but will also work with a Data View (DataFormWebPart). For the DataFormWebPart you will have a little more work to do as the WHERE is embedded in the "selectcommand" string and all of the brackets are "escaped". Example:
    image
    You will need to write the WHERE as a single line of text and replace each "<" with "&lt;" and each ">" with "&gt;".

The following is for SharePoint 2010 and Office 365 (2010)…

  1. If you don't have a convenient group for testing, go create a SharePoint group with a few people who can help you test this.
  2. In your list add a new column:
    Name: "VisibleToGroup"  (any name will do as long as you know how to deal with spaces and special characters in the name)
  3. Add a few items to the list with a few "VisibleToGroup" blank, a few with your test group and one or two for say Site Owners or Members.
  4. Create a view for a list:
    1. Give it a name (maybe "Filtered by Group Membership")
    2. Add a Filter. Anything will do. This is just to add the <Where> section to the web part's XML.  Example: Created By equals [Me]
    3. Configure the rest of the view as usual and save it
  5. Open your site in SharePoint Designer 2010
  6. In the Site Object pane click Lists and Libraries
  7. Click your list and then click the view you just created
  8. In the Code pane search for <Where>
  9. Delete everything between <Where> and </Where>  (but leave these tags)
  10. Add the following bolded code inside of the Where tags:
      <Where>
        <Membership Type="CurrentUserGroups">
          <FieldRef Name="VisibleToGroup"/>
        </Membership>
      </Where>

    The above for a DataFormWebPart (Data View):
    &lt;Where&gt;&lt;Membership Type="CurrentUserGroups"&gt;&lt;FieldRef Name="VisibleToGroup"/&gt;&lt;/Membership&gt;&lt;/Where&gt;
  11. Change "VisibleToGroup" to your column name (remember if you used spaces in the name then see: how to deal with spaces and special characters in the name)
  12. Save the view and go test in the browser

 

The results…

Here's a view showing all tasks in a list, including the People Picker column for a selected group displayed:

  image

Here's the filtered view for a user who is in the Training Members and Training Friends groups:

  image

Here's the filtered view for a user who is in the Training Friends and Training Members groups:

  image

The first user only saw tasks 2 and 4. The second user saw only tasks 2 and 3. Neither user saw task 1 as it was not assigned to any group.

 

Got a better solution?

Post a comment to this article and share it!

.

5/07/2012

SharePoint 2010, the Content Editor Web Part, and Broken Views…

 

The following is an excerpt from chapter 7 of my book SharePoint 2007 and 2010 Customization for the Site Owner. I keep getting questions on this so I thought I’d post it here. (You should still by the book!)

 

Adding a Content Editor Web Part to a view page like "Allitems.aspx" is a great way of customizing list and library views in SharePoint 2007. This generally had no negative impact, was easy to do and produced some major improvements with little work.

The Problem in 2010?

SharePoint 2010 treats view pages with added web parts as non-views and removes many view related features. I.e. adding a web part to a view breaks some things…

Here's a typical Task list All Tasks ("Allitems.aspx") view with the view menu clicked:

  image

Note these features:

  • The name of the view is displayed: Subsite 3 > Tasks > All Tasks
  • There are ribbon tabs for Browse, Items and List (or for a library, Documents and Library)
  • There is a dropdown arrow after "All Tasks" in the crumb trail

Here is the same view after the addition of a Content Editor Web Part (and the JavaScript to color code the task list):

  image

Note what's missing:

  • The name of the view in the crumb trail is missing
  • The ribbon tabs for Items and List are missing
  • The dropdown arrow after "All Tasks" in the crumb trail is missing
  • You can still get to the ribbon tabs, but you have to first click a row in the list:

        image

 

The Fix?

Don't add web parts to a 2010 view! (Duh) Instead, edit the page using SharePoint Designer 2010 and add your JavaScript code between the end tag for the Web Part Zone and the end tag for the PlaceHolderMain content tag.

    image

You can either embed the JavaScript:

    <script type="text/javascript">
        // js code here
    </script>

Or you can link to a text file with the JavaScript that you've uploaded to a library:

    <script src="../../SitePages/ColorCodedTaskList.txt" type="text/javascript"></script>

 

.

1/30/2012

A New SharePoint Designer 2010 Class

 

SharePoint Designer 2010 Class

This week I will deliver a new SharePoint Designer 2010 class at MAX Technical Training. We reviewed all of the existing classes we could find, and none met our requirements. The problem with most SharePoint Designer classes is that they focus on SharePoint Designer the program rather than what you can do with SharePoint Designer to customize your SharePoint sites. This class focuses on getting things done!

The first offering for this class is this Thursday, 2/2/2012 and covers both SharePoint 2010 and SharePoint Online / Office 365.

Not sure if this class is for you? Email me at image with any questions.

Here’s a partial list of the modules:

  • How SharePoint uses HTML, CSS and JavaScript
  • How SharePoint Uses ASP.NET and SharePoint Controls and how you can tweak them
  • Creating and Customizing Pages
  • Customizing SharePoint Navigation
  • Working with SharePoint Master Pages
  • The Data View Web Part – Creating Custom Views
  • The Data View Web Part – Working with XSLT
  • The Data View Web Part – Accessing External Data
  • JavaScript and CSS Tricks!

Except for the last bullet, this list does not hint at all of the tricks and tips I’ve included from playing working with SharePoint all of these years.

Here’s a few of those tips:

  • Convert Quick Launch to a pop out menu to save space
  • How remove the Quick Launch area from a page, or put it back in those pages where Microsoft hid it
  • Customize the page’s title area to display a banner, and as a bonus, get the 2007 style full crumb trail back
  • Create custom data entry forms for lists
  • Create a custom RSS web part to display RSS feeds from other SharePoint sites
  • Show or hide content and customizations based on permissions
  • Make the Tree View useful – show only libraries, or only show subsites etc
  • and more…

 

Register Now!

So, if you’d like to learn how to take the next level of control of your SharePoint site, click http://www.maxtrain.com/Classes/ClassInfo.aspx?Id=32766 and pop over to the MAX web site and sign up for this class.

Tell them Mike sent you and I’ll get you a free copy of my book or a SharePoint Designer book like this one.

 

MA-1083 - Sharepoint Designer 2010 - Customizing and Branding SharePoint

February 2, 2012 as MAX Technical Training

 

.

1/29/2012

SharePoint 2010: Cannot find ContentPlaceHolder 'PlaceHolderLeftActions' in the master page '~masterurl/default.master' #sharepoint #sp2010

 

A simple error caused by a minimal problem   ;-)

image

 

The odds are you or someone on your team was playing with master pages and set the minimal.master as the default master page. As the minimal master is not a complete master page, some of the place holders needed by many pages are missing.

 

SharePoint Designer

To fix, just go to SharePoint Designer and reapply the v4.master (or which ever master you normally use.)

    image

 

Site Actions, Site Settings

The Settings page has a fall back master page (Simplev4.master) to use whenever there is an error loading a master page. So if you don’t have SharePoint Designer available, and you are using a site based on a publishing template, then you can just navigate to the Site Settings page and pick a master page there.

http://yourserver/sites/yoursitecollection/_Layouts/settings.aspx

or just go directly to:

http://yourserver/sites/yoursitecollection/_Layouts/ChangeSiteMasterPage.aspx

Note, this only works with sites with the publishing features enabled.

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.