Link to item with edit menu

Sep 15, 2013 at 3:19 PM
Hello Ventigrate,

We installed your solution with great satisfaction. Thanks.

We want to create a column with the Link to item with edit menu.
We tried several scenarios like below but we cannot seem to get it rendered well.
Can somebody help on this?

FieldRefs:
<FieldRef Name="Title" />
<FieldRef Name="LinkTitleNoMenu" />
<FieldRef Name="_EditMenuTableStart2" />
<FieldRef Name="_EditMenuTableEnd" />
DisplayPattern:
<FieldSwitch>
    <Expr>
        <GetVar Name="FreeForm" />
    </Expr>
    <Case Value="TRUE">
        <Field Name="LinkTitleNoMenu" />
    </Case>
    <Default>
        <Switch>
            <Expr>
                <GetVar Name="MasterVersion" />
            </Expr>
            <Case Value="4">
                <HTML><![CDATA[<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
                <Field Name="_EditMenuTableStart2" />
                <HTML><![CDATA[">]]></HTML>
                <Field Name="LinkTitleNoMenu" />
                <HTML><![CDATA[</div>]]></HTML>
                <HTML><![CDATA[<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">]]></HTML>
                <HTML><![CDATA[<span>&nbsp;</span>]]></HTML>
                <HTML><![CDATA[<a onfocus="OnChildItem(this.parentNode.parentNode); return false;" onclick="PopMenuFromChevron(event); return false;" href="javascript:;" title="Open Menu"></a>]]></HTML>
                <HTML><![CDATA[<span>&nbsp;</span>]]></HTML>
                <HTML><![CDATA[</div>]]></HTML>
            </Case>
            <Default>
                <HTML><![CDATA[<table height="100%" cellspacing="0" class="ms-unselectedtitle itx" onmouseover="OnItem(this)" CTXName="ctx]]></HTML>
                <Field Name="_EditMenuTableStart2" />
                <HTML><![CDATA["><tr><td width="100%" class="ms-vb">]]></HTML>
                <SetVar Name="ShowAccessibleIcon" Value="1" />
                <Field Name="LinkTitleNoMenu" />
                <SetVar Name="ShowAccessibleIcon" Value="0" />
                <HTML><![CDATA[</td><td><img src="/_layouts/images/blank.gif" width="13" style="visibility:hidden" alt=""/></td></tr></table>]]></HTML>
            </Default>
        </Switch>
    </Default>
</FieldSwitch>

Kind regards,
Mario
Coordinator
Nov 7, 2014 at 9:08 AM
Which SharePoint edition are you using?
Nov 7, 2014 at 9:13 AM
Hello VanDest,

Nice of you to reply. Thanks.
At present we use sharepoint foundation 2010.

Kind regards,
Mario
Coordinator
Nov 7, 2014 at 2:54 PM
Hi,

I haven't succeeded in this myself with SharePoint 2010. I think this would require additional attributes "ListItemMenu" and "LinkToItem" on the Field schema.
Details: http://styledpoint.com/blog/how-to-create-a-custom-field-column-on-a-sharepoint-2010-list-library/

So either create a custom field for this or run the following PowerShell ;) It can be on an out of the box field.
asnp Microsoft.SharePoint.PowerShell -ea 0 | Out-Null

$w = Get-SPWeb http://intranet/sites/x
$l = $w.Lists["Shared Documents"]
$f = $l.Fields["MyField"]

# SET
$mi = [Microsoft.SharePoint.SPField].GetMethod("SetFieldAttributeValue", [System.Reflection.BindingFlags]"NonPublic, Instance")
$mi.Invoke($f, @("ListItemMenu", "TRUE"))
$mi.Invoke($f, @("LinkToItem", "TRUE"))
$f.Update()

# See if added
$f.SchemaXml
Marked as answer by vandest on 3/16/2015 at 5:13 AM