Tuesday, May 9, 2017

Click default "Browse" tab of ribbon on New/Edit forms to reset the ribbon instead of Edit tab - SharePoint

Write the following code in your window.onload() :- 

--------------------------------------------------------------------------------------
function ResetRibbon() {
            try {
                var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
                SelectRibbonTab("Ribbon.Read"true);
                ribbon.removeChild("Ribbon.ListForm.Display");
                ribbon.removeChild("Ribbon.ListForm.Edit");
            } catch (e)
            { }
        }

        SP.SOD.executeOrDelayUntilScriptLoaded(function () {
            try {
                var pm = SP.Ribbon.PageManager.get_instance();

                pm.add_ribbonInited(function () {
                    ResetRibbon();
                });

                var ribbon = null;
                try {
                    ribbon = pm.get_ribbon();
                }
                catch (e) { }

                if (!ribbon) {
                    if (typeof (_ribbonStartInit) == "function")
                        _ribbonStartInit(_ribbon.initialTabId, falsenull);
                }
                else {
                    ResetRibbon();
                }
            } catch (e)
            { }

        }, "sp.ribbon.js");

No comments:

Post a Comment

Clearing Person/Group Values

To clear out or empty the values in person or group columns, how you do it depends on if the column is single-value or multi-value. For ...