SharePoint Designer \ Data Form Web Part context menu bug
Posted
Wednesday, May 07, 2008 11:54 AM
by
Itay Shakury
Update: Read the follow up post for a permanent fix to this bug: SharePoint Designer \ Data Form Web Part context menu bug - Part 2
Update 2: There is a hotfix that automates this fix: http://blogs.microsoft.co.il/blogs/itaysk/archive/2008/11/18/sharepoint-designer-data-form-web-part-context-menu-bug-part-3.aspx
This bug was confirmed by Microsoft after we opened a "Severity A" issue on it. The original response from the support guy was : "oh my god!" :) because this kind of bugs are really easy to track down in a superficial QA testing. Eventually the support guys couldn't help us and registered that as a SharePoint Designer bug. But worry not - Itaysk to the rescue..
Problem:
You try to use a Data Form Web Part (Data View Web Part) to display a document library in an XSLT view. You find out that the context menus for list items are identical for all items, even tough you know they should be different.
Steps to reproduce:
- Create a document library. Add at least 2 items to the document library, modify the permissions for one item to read only.
- Notice that each item has a different context menu.
- Open SharePoint Designer 2007, and browse to the document library. Open the page you have just viewed (Forms\Allitems.aspx)
- In design mode, right click on the document library web part (List View Web Part) and click on "Convert to XSLT view".
- Save the page, and open it in browser.
- Notice that now all the items share the same context menu. In fact, it is the context menu for the first item in the list.
Cause:
This behavior is caused by the XSLT code that SharePoint designer generates for the document library.
When each item is rendered, the current user's permission for that item is written in the HTML code for that item. It is represented by the "Perm" attribute of the table that contains the item.
When the user clicks on the item in order to open it's context menu, SharePoint looks for that "Perm" attribute and renders the menu accordingly.
Now, the XSL code that SPD generates writes wrong values into this "Perm" attribute. It uses the "CurrentRights()" function of the "ddwrt" namespace, and apparently this method doesn't not work well here.

Solution:
Use the "PermMask" property instead of the "CurrentRights()" function:
- Open SharePoint Designer 2007 and navigate to the page containing the Data Form Web Part. (follow the "Steps to Reproduce" above)
- In Code view,search for the following peace of code:
Perm="{ddwrt:CurrentRights()}"
- Replace it with the following peace of code:
Perm="{@PermMask}"
- Save the page.
That's it, now browse again to that page you have just modified, and see for yourself - each item has it's own, correct, security trimmed, context menu.
