How to refresh List View in SharePoint 2013 using JavaScript

One of the short tip to refresh the list view using JavaScript code is as below:

// Set Ajax refresh context
var evtAjax = {
  currentCtx: ctx,
  csrAjaxRefresh: true
};
// Initiate Ajax Refresh on the list
AJAXRefreshView(evtAjax, SP.UI.DialogResult.OK);

You can place this code after completing your operation on list item or on success method. Where ctx is the current site context.

var ctx = SP.ClientContext.get_current();

This code usually helps in Client Side Rendering (CSR) / JSLink.

Keep SharePointing!

How to verify if the Page is in Edit mode using JavaScript in SharePoint 2013

Hi Guyz,

In one of my project there was need to have a specific edit mode functionality to be implemented, so there might be lot of approaches we can have but I found some of the below approaches that we can implement to verify if the page is in edit mode using JavaScript.

For Publishing Page
SharePoint default input called MSOLayout_InDesignMode is there. If the value is 1 then page is in edit mode else it is in display mode.

var inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value;

if (inDesignMode == "1")
{
   // page is in edit mode
}
else
{
   // page is in browse mode
}

This will refer to value of the following html input control, which is rendering on the page when it is in edit mode:

<input id="MSOLayout_InDesignMode" name="MSOLayout_InDesignMode" type="hidden" value="1" />

For Wiki Pages
Same as above another default input _wikiPageMode parameter will be used. If the value is Edit page is in edit mode else in display mode.

var wikiInEditMode = document.forms[MSOWebPartPageFormName]._wikiPageMode.value;
if (wikiInEditMode == "Edit")
{
   // wiki page is in edit mode
}
else
{
   // wiki page is not in edit mode
}

Custom Code Snippets
Also you can place some snippet control to master page or page layout if you have customized it and place following snippets:

<PublishingWebControls:EditModePanel ID="EditModelPanel1" runat="server" PageDisplayMode="Edit">
    <h1>You are in EDIT mode</h1>
    <!-- Place you're javascript for execute only in edit mode -->
</PublishingWebControls:EditModePanel>

<PublishingWebControls:EditModePanel ID="EditModelPanel2" runat="server" PageDisplayMode="Display">
    <h1>You are in DISPLAY mode</h1>
    <!-- Place you're javascript for execute only in display mode -->
</PublishingWebControls:EditModePanel>

Cheers!

Enable “Sign In As Different User” in SharePoint 2013

In SharePoint 2010, there was a option available for signing as a different user. But in SharePoint 2013, that option has been removed.

Without Sign In option

I don’t know why Microsoft has removed this precious feature, but there are some workarounds to get back that feature.


Workaround 1:

  • Start Internet Explorer by using the Run as different user option, and then go to the SharePoint site.
    Note: The Run as different user option is visible if you hold the Shift key when you right-click a program icon.
  • Access the SharePoint site by using the the URL as http://siteurl/_layouts/15/closeConnection.aspx?loginasanotheruser=true
    Important: This option uses an unsupported browser feature which is unreliable and causes other issues. Currently this option does not work in IE 10 and Safari.

Workaround 2:

  • Go to the location C:\Program Files\Common Files\microsoft shared\Web ServerExtensions\15\TEMPLATE\CONTROLTEMPLATES
    There will be file called Welcome.ascx
    WelcomeEdit
  • Open welcome.ascx in Visual Studio or in Notepad and add the following code and save.<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />Edit Welcome.ascx
  • Once you save this file, the feature will be enabled.
    With Link

Very simple workarounds to get back this feature.

Cheers!

Add Breadcrumb with SharePoint 2013 Design Manager

Greetings Guyz,

One day i was in need to have my custom breadcrumb with Design Manager feature in SharePoint 2013, so i dug into it and found that there is one snippet code to add breadcrumb in our HTML page of master layout. We just need to put below snippet to our any of the master page or page layout where you want to place the breadcrumb.

<div id="breadcrumb">
<!--MS:<ASP:SITEMAPPATH runat="server" sitemapproviders="SPSiteMapProvider,SPXmlContentMapProvider" rendercurrentnodeaslink="false" hideinteriorrootnodes="true" RootNodeStyle-CssClass="bc-root">-->
<!--MS:<PATHSEPARATORTEMPLATE>-->
<!--MS:<ASP:IMAGE id="Image1" runat="Server" imageurl="/_catalogs/masterpage/images/breadcrumb_line.png">-->
<!--ME:</ASP:IMAGE>-->
<!--ME:</PATHSEPARATORTEMPLATE>-->
<!--ME:</ASP:SITEMAPPATH>-->
</div>

Through above snippet we can have custom breadcrumb. Now to fulfill your requirement to have the actual branding you can create or update CSS classes or write some scripts using jQuery.

Blog more, Help more..!

Cheers!