Modifying the Edit Control Block
If you have ever used Windows, or any computer for that matter you will have been introduced to the context menu idea. Click on something and a fly out menu gives you a load of choices.
SharePoint uses this as well and most of the time it is just fine.
But what about those times when you want to add something to that list that can save you time, a shortcut that makes perfect sense but is not there.
Working the other day, a client wanted a document library but only have items appear on a list that have not been read. An everyday task that can be solved with a dose of SharePoint services.
Making a list view was easy enough, we added an extra column with a selection field: read or unread. Then we can make a custom view that will display only unread items.
The customer was happy and the birds were singing in the trees.
Then they came back and asked if there could be an option in that context menu that will enable them to mark an item as read. It makes perfect sense from a user ability point of view. Currently to mark an item as read you need to edit that item, update the read status, save the item, and return to the previous view. Yet if we could change that context menu the status could be updated with a single mouse click.
We went back to the drawing board wondering how difficult it would be to modify the Edit Control Block, the technical term for the context fly out menu. After a bit research it turned out to be easier than we first thought. Instead of ripping apart SharePoint web services and creating custom builds and other complicated stuff we could do it with a bit of JavaScript!
Jan Tielen’s had discovered that there a little known method in the core JavaScript files of SharePoint that allows you to create custom fly out menu’s.
With this knowledge in hand we set about applying this to the project in hand. With a little bit of JavaScript magic connecting the list to the library and the library to the Control Block we were able to deliver a simple status update to the context menu.
Ok, we are the first to admit that this will never set the world on fire and is not going to win us any developer awards, but the customer has now halved their workflow so the birds are singing again.