4

I don't understand how in SharePoint you can activate a right-click context menu on the rows of a list web part.

I have two different pages. In each page I have 4 views. For some reasons (?) in page A when I right-click an item row the standard ecb context menu appears; while in page B when I right-click an item row, the system shows menu the standard browser context menu.

Looking at the HTML code of the view rows I can see that the difference is in how the tr element is configured. The property oncontextmenu must have ShowCallOutOrECBWrapper call. In page A I have:

<tr class=" ms-itmHoverEnabled ms-itmhover" oncontextmenu="return ShowCallOutOrECBWrapper(this, event, false)" iid="14,47,0" id="14,47,0" setedgeborder="true">

While in page B the HTML shows:

<tr class=" ms-itmHoverEnabled " iid="3,47,0" id="3,47,0" setedgeborder="true">

How do I activate the same behavior in page B?

2

I finally discover my self how SharePoint behaves with ECB controls and how user can control the OOB behavior using CSR and JSOM.

It seems that the behavior described in my question depends whether you show the field Title (with link to Edit menu) is selected in the view: if your LWP is configured to show that field, the ECB menu will be displayed on right click (on any row cell). Otherwise, on right click, the browser context menu will be displayed.

Actually, I can see that this is partially true: SharePoint will show the context menu on right-click if you have at least one field with ECB enabled. So, how to control ECB, for example, if I don't want display the Title (with link to Edit menu)?

"Easy". Using the CSR engine, you can modify the ListSchema of the web part context. From here, you can access the schema of the fields and set the properties as you require (e.g. listItemMenu). Obviously you must add you customization to OnPreRender and override the client template according to the CSR pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.