Поделиться через


Enable Ribbon on item selection in SharePoint 2013

With every version of SharePoint Microsoft changes a lot that its hard to adjust with new version. It takes bit of time to get used to the new changes in new version. Just an example In SharePoint 2007 the Site Actions menu was in the right corner of the screen, in SharePoint 2010 the Site Actions moved to left of the screen, again in SharePoint 2013 the Site Actions(gear icon) is moved to the right corner of the screen.

In SharePoint 2010 the ribbon is by default selected when an item is selected, but in SharePoint 2013 the ribbon is not selected by default. So I tried hard to find a setting which can help in enabling the ribbon by default. But no luck. Tried searching a lot but didn't find a direct way to do so. Here in this article I will help you in enabling the ribbon when selecting an item in SharePoint 2013.

Why by default the ribbon is not selected in SharePoint 2013

The new UI reflects their “Minimal Download Strategy” in SharePoint 2013 that improves rendering performance when browsing content where large parts of the page do not change, which provides a more fluid navigation experience.

Now the question is How Ribbon can be enabled ?

// JavaScript source code
function ShowItemsMenuWhenItemsSelected() {
    var oldToggleItemRowSelection = ToggleItemRowSelection;
    ToggleItemRowSelection = function (ctxCur, tr, fSelect, a, b) {
        oldToggleItemRowSelection(ctxCur, tr, fSelect, a, b)
        
        if ((ctxCur.CurrentSelectedItems > 0) && (ctxCur.listBaseType == 0) && (ctxCur.ListTemplateType == 171)) {
            SelectRibbonTab("Ribbon.Tasks", true);  //open the ribbon for tasks list
        }
        else if ((ctxCur.CurrentSelectedItems > 0) && (ctxCur.listBaseType == 1)) {
            SelectRibbonTab("Ribbon.Document", true);  //open the ribbon for Documents Library
        }
        else if (ctxCur.CurrentSelectedItems > 0) {
            if ((ctxCur.listBaseType == 0) || (ctxCur.listBaseType == 5))
            {
                SelectRibbonTab("Ribbon.ListItem", true);  //open the ribbon for List items
            }
        }
        else {
            SelectRibbonTab("Ribbon.Read", true);  //close the ribbon
        }
    }

_spBodyOnLoadFunctionNames.push("ShowItemsMenuWhenItemsSelected");

Comments

  • Anonymous
    September 20, 2016
    Helpful...