Sunday, October 28, 2012

Hide list column headers of a list view webpart

Hide list column headers of all list view webparts on the page

  1. Add a Content Editor WebPart (CEWP) to the page
  2. Use the following CSS:

Hide column headers of a specific list view webpart

The method, described in the following blogpost will definitely work (find listview by title), but there is a downside with this method. What if the end user renames the list? Our solution will break.

I think it's safer to find a listview by URL. The URL is fixed and cannot be changed from the UI (only with SharePoint Designer).
  1. Add a Content Editor WebPart (CEWP) to the page
  2. Use the following JQuery script: !! Don't forget to change the URL to the URL of your list

Saturday, October 20, 2012

SharePoint 2013 - Short Introduction to Animation Engine

Already noticed the "fade in" effect on the page while browsing in SharePoint 2013?
No? Open a standard Teamsite and focus the main content...


So, how does this work?

Some site templates uses the Minimal Download Strategy (MDS) framework. This framework consists of several components working together to only download the changes between the different pages. The main component is the start.aspx application page (as I said, there are more components to make this work). This page is responsible for loading pages from the site using the MDS. I don't want to write an in-depth article about MDS here...our main focus is the animation effect, remember? :) The codebehind of this page is defined in the following class: Microsoft.SharePoint.ApplicationPages.MDSStartPage.

The startpage will, among other things, register the start.js script. This script contains a javascript object, called the AsyncDeltaManager. This object will handle the delta requests/responses. When the AsyncDeltaManager retrieves a delta, he will call (at the end) the BeginTransitionAnimation() javascript function. This function does the preparation for the animation effect, ONLY if the MDS animation is enabled. At the end, the animation effect will be started in the EndTransitionAnimation() function. This is where the magic happens. He will call the SPAnimationUtility.BasicAnimator.FadeIn(content, null, null); command!

As far as I know, the fade effect is only used for the following placeholders:
  • PagetitleInTitleArea
  • Main

Can we disable the animation effect?

Yes, we can! (HTML5) web storage is used to enable/disable the animation effect. Below you'll find a couple of commands you can use...
SPAnimation.Settings.EnableAnimation(); //enable animation
SPAnimation.Settings.DisableAnimation();//disable animation
SPAnimation.Settings.DisableSessionAnimation();//disable animation only for this session
ToggleAnimationStatus();//toggle animation
SPAnimation.Settings.IsAnimationEnabled(); //check whether animation is enabled

Monday, October 15, 2012

Display animated spinner while loading modal dialog

The following javascript function SP.UI.ModalDialog.showModalDialog(options); is a way to display a modal dialog with specified dialog options. When you assign a value to the URL property of the dialog options, an IFRAME tag is rendered pointing to the appropriate URL.

ShowDialog example
var options = {
    title: "My Dialog Title",
    width: 400,
    height: 600,
    url: "/_layouts/DialogPage.aspx" };

To display an animated spinner, you can set a background-image for the iframe with some CSS.

    background-image: url("../images/animatedspinner.gif");        
    background-repeat: no-repeat;     
    background-position: 50% 50%; 


Wednesday, August 1, 2012

Extract details from a WebException

    //Do something
catch (WebException ex)
    using (var stream = ex.Response.GetResponseStream())
    using (var reader = new StreamReader(stream))
        string errormessage = reader.ReadToEnd();
catch (Exception ex)
    //Do something

Monday, July 30, 2012

Easily embed Youtube videos, Javascript, styles and other markup into a SharePoint 2013 page with the Script Editor WebPart

Instructions below are executed within a Team Site template:
  1. Select the ‘Edit’ icon in the top right corner of the page to edit the page

  2. Select ‘Page’ in the ribbon, click ‘Embed Code

  3. Enter some script, styles, embed code,… in the editor box

    Javascript example

    Youtube example


    Notice the preview of the embedded video
  4. Click ‘Insert
  5. Save the page with ‘Save & Close’ in the top right corner.
Some remarks:
  • After clicking ‘Insert’, a Script Editor WebPart will be automatically inserted into the page - only if you’re using embedded code.

  • Default Chrome type is ‘None’
  • The Script Editor WebPart is also available as webpart under ‘Media and Content’

  • You can still use the Content Editor Webpart to achieve the same results. The main difference between the two is that the Content Editor WebPart  is more focused to  enter rich text content, while the new Script Editor WebPart is more focused to insert HTML snippets and scripts.

Saturday, June 23, 2012

SharePoint Sucks – And Here’s Why...

What would you do when you see this message?


A) Stay calm, try to copy the correlation ID, notice that you can’t copy it and still stay calm, write it down on a piece of paper and track it in the ULS logs

B) Open your browser, go to a search engine and type “SharePoint sucks” to let off steam

If you have chosen option B, you’ll probably encounter the funny blog series of Bjørn Furuknap. Give it a read, they are a bit outdated but there’s still a lot of truth in it.
Ow, btw, I didn’t search after “SharePoint sucks” – it was a colleague who mentioned the blog series. He has probably chosen for option B. Ok, to be honest, there are days that I hate SharePoint too. I have some sort of love/hate relationship with it.

Let me end this post with a funny quote of Bjørn Furuknap.
Over the past couple of weeks, I’ve said quite a lot of things about SharePoint that may lead you to think I hate SharePoint. I don’t. Quite the contrary, I love SharePoint. Yeah, it sucks, but so does my wife, and I’ve married her twice.

Sunday, June 17, 2012

Quick Tip: Approval Workflow - Due date for all tasks

Within the association form of the approval workflow you are able to set the “Due Date for All tasks”. This setting specifies the date by which all tasks are due.

What if you want tasks to become due on a specific time on a specific day? In the user interface of the association form you are not able to specify a time value.


Although it is nowhere documented, it is possible.

For example, if you want to terminate all tasks on the 18th of June at 13h30 you can set the following value in the textbox:

Use the following structure to set a time value:

I know, it’s not really user friendly, but it works. You can probably use SharePoint Designer to tweak the association form to implement some extra logic.

One of the best references online about approval workflows in SharePoint 2010: All about approval workflows

Wednesday, February 29, 2012

Export Farm Solution Package with PowerShell

Follow the steps below to export a farm solution package…

1. Open a text editor – such as Notepad.
2. Paste the following code snippet:

$farm = Get-SPFarm
$file = $farm.Solutions.Item("MySolutionPackage.wsp").SolutionFile

3. Replace the highlighted text above with the name of your solution package.
4. Save the file - give the file a name and save it with the extension ps1 (eg. extract.ps1) and place the file on the C:\ drive.
5. Open the SharePoint 2010 Management Shell
6. Navigate to the location of the script and execute it.
7. The solution package will be available on the C:\ drive

Update: If you want to download all the solutions at once you can use the following script:
$dirName = "C:\Solutions"
foreach ($solution in Get-SPSolution)
$filename = $Solution.SolutionFile.Name

Thursday, February 16, 2012

Error: The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service...

This error can be encountered while viewing an InfoPath form in the browser. In most cases, the problem can be solved by reading through the following blogpost.

In my case, the state service was enabled and the service application was correctly associated with the webapplication. I solved this by deleting the 'corrupt' state service database, creating a new one and attaching the new database to the farm - all these steps can be done with some Powershell commands.