{"id":1604,"date":"2016-03-17T16:49:50","date_gmt":"2016-03-17T15:49:50","guid":{"rendered":"http:\/\/blog.kodono.info\/wordpress\/?p=1604"},"modified":"2016-07-06T16:12:36","modified_gmt":"2016-07-06T14:12:36","slug":"play-with-ribbon-on-sharepoint","status":"publish","type":"post","link":"https:\/\/blog.kodono.info\/wordpress\/2016\/03\/17\/play-with-ribbon-on-sharepoint\/","title":{"rendered":"Play with ribbon on Sharepoint"},"content":{"rendered":"<p>In Sharepoint 2010 and 2013, there are some existing functions to deal with the ribbon.<\/p>\n<p>Below an example of what we can do:<\/p>\n<pre class=\"brush:javascript\">\r\n\/\/ we need the file \"sp.ribbon.js\"\r\nSP.SOD.executeOrDelayUntilScriptLoaded(function () {\r\n  \/\/ use PageManager\r\n  var pm = SP.Ribbon.PageManager.get_instance();\r\n\r\n  \/\/ define a function to call when the ribbon is loaded\r\n  var DoSomethingWithRibbon=function(ribbon) {\r\n    \/\/ For example, we can select the \"Browse\" tab\r\n    ribbon.selectTabById(\"Ribbon.ListForm.Display\", true);\r\n    \/\/ Note: You can explore the DOM to find the related IDs\r\n    \/\/ other example \"Edit\" tab is \"Ribbon.ListForm.Edit\"\r\n  \r\n    \/\/ We can now remove the \"Edit\" tab\r\n    ribbon.removeChild(\"Ribbon.ListForm.Edit\");\r\n  }\r\n\r\n  \/\/ perform an action when the ribbon has been inited\r\n  pm.add_ribbonInited(function () {\r\n    DoSomethingWithRibbon(pm.get_ribbon())\r\n  });\r\n\r\n  \/\/ if the ribbon is already loaded\r\n  var ribbon = null;\r\n  try {\r\n    \/\/ get an instance of the ribbon\r\n    ribbon = pm.get_ribbon();\r\n  } catch (e) {}\r\n  if (!ribbon) {\r\n    if (typeof(_ribbonStartInit) == \"function\")\r\n      _ribbonStartInit(_ribbon.initialTabId, false, null);\r\n  } else {\r\n    DoSomethingWithRibbon(ribbon);\r\n  }\r\n\r\n}, \"sp.ribbon.js\");\r\n<\/pre>\n<p>And there are also solutions to add stuff to the ribbon. I have to dig into these solutions&#8230; In the meantime you can try <a href=\"https:\/\/dbremes.wordpress.com\/2011\/01\/16\/theres-a-javascript-api-for-creating-ribbons\/\">this blog post<\/a>, or <a href=\"http:\/\/www.umtsoftware.com\/blog\/creating-sharepoint-ribbon-elements-in-javascript\/\">this one<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Sharepoint 2010 and 2013, there are some existing functions to deal with the ribbon. Below an example of what we can do: \/\/ we need the file &#8220;sp.ribbon.js&#8221; SP.SOD.executeOrDelayUntilScriptLoaded(function () { \/\/ use PageManager var pm = SP.Ribbon.PageManager.get_instance(); \/\/ define a function to call when the ribbon is loaded var DoSomethingWithRibbon=function(ribbon) { \/\/ For [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","hide_page_title":"","footnotes":""},"categories":[15,13,33],"tags":[24,152,158,117],"class_list":["post-1604","post","type-post","status-publish","format-standard","hentry","category-astuce","category-niveau-intermediaire","category-programmation","tag-javascript","tag-niveau-intermediaire","tag-programmation","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1604"}],"version-history":[{"count":6,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1604\/revisions"}],"predecessor-version":[{"id":1674,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1604\/revisions\/1674"}],"wp:attachment":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}