窗外

Enabling ECB menu on a custom column in SharePoint 2010 (Part 1)

If you have ever tried to enable the ECB menu on a column other than Name or Title in MOSS 2007, you will love a new feature of SharePoint 2010, Show List Item Menu, like the screenshot below. This feature allows us to enable the ECB menu on almost all columns.

image

In SharePoint Designer, if we select this option and save our changes, the ECB menu will be enabled on this column.

image

It works very well on the columns in lists. However, there is a little problem when we use this feature on a column in the document library. For example, when I enable the ECB menu on Title of a document library, the ECB menu is displayed as below. ( I also put a screenshot for the ECB on Name column for the contrast. )

image

image

It shows “Edit in undefined” instead of “Edit in Microsoft Word” which is expected to be shown. And if I click on this menu item, I got the following error with no surprise, although Microsoft Word has been installed on this machine.

image

Why this problem happens is because in SharePoint 2010 the ECB menu is generated and rendered by a set of JavaScript calls dynamically. When in document library, those calls will try to determine the document type with the current column and add a menu item displayed as “Edit in Microsoft Word” or “Edit in Microsoft Excel” etc according to the type returned. For Name column whose field type is LinkFilename, the JavaScript calls can retrieve the file type because this column has a reference to the field FileLeafRef. But for Title column here, since it does not have the reference to FileLeafRef, the calls simply return an undefined.  For some reason, these JavaScript calls work fine with the Name column whose field type is LinkFilename. The document type can be retrieved. But for the Title column, the calls simply return an undefined. Looks like the code does not check whether the returned value is undefined or not, therefore we see “Edit in undefined” in the menu.

This might be a bug of the code. At least an error checking here is necessary. If the returned value is undefined, the ugly “Edit in undefined” should not be shown. But before there is an official fix, actually I have no idea whether it will be fixed or not, is there any way to enable an ECB menu with “Edit in Microsoft Word” on Title column? Well, I am going to answer this question in the part 2 of this topic.

Leave a Reply

Your email address will not be published. Required fields are marked *