SharePoint Designer \ Data Form Web Part context menu bug

7 במאי 2008

16 תגובות

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:



  1. Create a document library. Add at least 2 items to the document library, modify the permissions for one item to read only.
  2. Notice that each item has a different context menu.
    ctxbefore
  3. Open SharePoint Designer 2007, and browse to the document library. Open the page you have just viewed (Forms\Allitems.aspx)
  4. In design mode, right click on the document library web part (List View Web Part) and click on "Convert to XSLT view".
    convertxslt
  5. Save the page, and open it in browser.
  6. 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.
    ctxmiddle

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.


permattbefore


Solution:
Use the "PermMask" property instead of the "CurrentRights()" function:



  1. Open SharePoint Designer 2007 and navigate to the page containing the Data Form Web Part. (follow the "Steps to Reproduce" above)
  2. In Code view,search for the following peace of code:
    Perm="{ddwrt:CurrentRights()}"
  3. Replace it with the following peace of code:
    Perm="{@PermMask}"
  4. 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.
ctxafter

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

16 תגובות

  1. Lior Arviv7 במאי 2008 ב 17:41

    Good to know 🙂

    הגב
  2. Penny Coventry7 במאי 2008 ב 19:29

    Great fine and well explained.

    הגב
  3. Elad Khalo7 במאי 2008 ב 19:42

    Itay, your'e the best!

    הגב
  4. Zullu12 ביוני 2008 ב 23:55

    That is wierd, but you definitely have the solution.
    Kudos to you Itay.

    הגב
  5. Encuctimbunc15 ביולי 2008 ב 14:43

    I don't say we all ought to misbehave, but we ought to look as if we could.–Orson Welles, (1915 – 1985), U.S. actor/director

    הגב
  6. unsulk16 ביולי 2008 ב 11:31

    Your friend is that man who knows all about you, and still likes you.–Elbert Hubbard U.S. editor/publisher

    הגב
  7. Russ K17 בספטמבר 2008 ב 16:40

    I think there are several other bugs in the context menu. "Add to My Links" is not there in a ListView (I'm using WSS, not MOSS"), but it shows up after converting to a DFWP because ctx.PortalUrl is set to "web" instead of "". If your library has versioning enabled, a menu item "Version History" exists before the conversion to DFWP, but not after. The XSLT to set ctx.verEnabled doesn't work.
    The bug you mention above also causes the Manage Permissions menu item to disappear after conversions (assuming you had enough rights to see it before the conversion!). This fixed the problem for me – prefix 0x to the Perm attribute: i.e. Perm="0x{ddwrt:CurrentRights()}", but your fix is cleaner.
    The toolbar formatting changes during conversion also – some classes change and background images go away.
    The css classes generated for DocIcon and Name (with edit menu) columns also change.
    Have you seen issues like these? Anyone?

    הגב
  8. Michael1 ביולי 2009 ב 4:34

    Hi,

    Would you like to drive more traffic to your website?

    Delivering promotions to your current clients can generate you great income at an afforable price.

    Main reasons why work with us:

    Results – will get all of your emails delivered to your clients' inbox.

    Economical – low prices and the best ROI you can get when marketing online.

    Automation – lists management, campaigns scheduling, statistics and autoresponder.

    Optimized Design – design your newsletter online, preview and test deliverability.

    For more information please visit http://www.mailer365.com

    Thanks,
    Michael.

    הגב
  9. Rudy1 בדצמבר 2009 ב 21:07

    Hello,

    My name is Rudy and after examining your website, I believe I can help you improve your Search Engine Rankings.

    Do you wish you could increase your online leads? Getting much more traffic from search engines?
    It is much easier and more cost-effective than you might think. For as low as $99 we have helped a lot of businesses thrive in this market and we can help you!
    Mail me at seo.rudy@gmail.com if you are interested in outranking your competition. I will contact you back, after an examination, with an analysis and recommendations.

    הגב
  10. icons18 בספטמבר 2012 ב 1:15

    Thanks for the information, can, I too can help you something?

    P.S. Please review 16×16 Pixel Toolbar Icons from icojamcom81

    הגב
  11. icons18 בספטמבר 2012 ב 10:56

    I apologise, but you could not give little bit more information.

    P.S. Please review Scan Icon from graphic-icons

    הגב
  12. Wicks22 בינואר 2013 ב 2:05

    I really like looking through an article that can make people think.
    Also, thank you for allowing for me to comment!

    הגב
  13. Willingham30 בינואר 2013 ב 19:44

    This post is genuinely a pleasant one it helps new internet viewers, who are wishing for blogging.

    הגב
  14. Pitman18 בפברואר 2013 ב 21:12

    Quality articles is the key to attract the visitors to
    pay a visit the site, that's what this web site is providing.

    הגב
  15. Pate24 בפברואר 2013 ב 6:07

    Hi, just wanted to say, I liked this article. It
    was practical. Keep on posting!

    הגב
  16. Colvin31 במרץ 2013 ב 10:36

    Thanks for finally writing about >SharePoint Designer \ Data Form Web Part context menu bug – itaysk הגב