Posts Tagged ‘Server Side Conditions’
Dynamic EditControlBlock menu items
As a SharePoint developer, you often have to struggle with certain platform limitations. One of those limitation is the fact that the EditControlBlock (The list item contextual drop down menu) does not support menu items display based on server sided conditions. For example, you cannot do something like say: only display this menu when the document has a metadata value of “approved” in a specific column.
As a SharePoint product developer, this is a major problem since we have, to date, 11 products that sit on top of SharePoint some of which use this contextual menu in order to display available features to the end-user.
Let’s take as an example render-It, a document transformation product that allows documents like doc or docx documents to be transformed in another format like pdf, html etc… Everyone will agree that this “rendering” menu item should not be displayed unless the current document meets the requirements for the transformation. Some people on the web have taken an approach where they modify or override the core.js functions and add their own logic. This was not an option for us since we wanted a “non-intrusive” way of adding our logic to existing functions.
So instead, we used the reflective nature of the JavaScript language to “hook” up to existing core.js functions and modify their parameters in order to add our own menus at run time by making some ajax calls. This preserves the original core.js functions and prevents bugs due to possible upgrades or changes Microsoft might implement in the core.js.
This nifty little trick allows us to make an Ajax call to the server at run-time in order to validate if a specific menu item should be displayed for this specific item in this specific context. It makes the end-user experience much more enjoyable by not having 5-6 menu items that will give you an handled error message after you click on it like ‘this action is not valid for this item” which is very unpleasant.
The result is a much more intuitive editcontrolblock menu with menu items available only when specific feature requirements are met by the current item, security, type, metadata etc….