We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Context menu doesn''t work for itemtemplate column

If the column type is Item template then the context menu doesn't show up :(

1 Reply

RP Rekha P Syncfusion Team May 14, 2009 01:58 PM UTC

Hi Girish,

Thank you for your interest in Syncfusion Products.

We regret to let you know that currently it is not possible to show the context menu over the Item Templates. But as a workaround, please refer the sample below which illustrates of displaying Menu control as popup while hovering on image item template.

http://files.syncfusion.com/support/GGC.Web/7.103.0.21/55067/main.htm

Steps followed are:
1. Place Image and PopupControlContainer inside ItemTemplate.
2. Place Menu control inside PopupControlContainer.
3. For every row bounding, set corresponding MenuItem text, PopupControlContainer clientobjectid and attribute for image mouse over event.
4. Capture the popup clientobjectid using js function by evaluating it.

Please refer the code snippet below to achieve this.

[ASPX]



















[C#]

void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e)
{
if (e.Element.Kind == Syncfusion.Grouping.DisplayElementKind.Record)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)
{
//check ItemTemplate column name
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "Image")
{
Syncfusion.Web.UI.WebControls.Tools.Menu ContextMenu = (Syncfusion.Web.UI.WebControls.Tools.Menu)e.Row.Cells[i].FindControl("Menu1");
if (ContextMenu != null)
{
//bind text to MenuItem
ContextMenu.Items[0].Text = e.Row.Record.GetValue("Name").ToString();
}
Syncfusion.Web.UI.WebControls.Shared.PopupControlContainer PopUp = (Syncfusion.Web.UI.WebControls.Shared.PopupControlContainer)e.Row.Cells[i].FindControl("PopupControlContainer1");
if (PopUp != null)
{
//specify ClientObjectId of PopupControlContainer
PopUp.ClientObjectId = e.Row.Record.GetValue("Name").ToString();
}
System.Web.UI.WebControls.Image ContextMenuImage = (System.Web.UI.WebControls.Image)e.Row.Cells[i].FindControl("ContextMenuImage");
if (ContextMenuImage != null)
{
ContextMenuImage.Attributes.Add("onmouseover", "Showpopup('"+PopUp.ClientObjectId+"')");
}
}
}
}
}
}

[Javascript]

We can trigger the PopupControlContainer's ClientObjectId by evaluating the expression.



If you want to display the popup with corresponding hovered Image's, please use the below code.



For more information about PopupControlContainer, refer to ASP.Net --> Controls and Components --> Notification Package --> PopupControlContainer

http://help.syncfusion.com/ug_71/toolsweb/default.html

Please let me know if you have any concerns.

Thanks,
Rekha

Loader.
Live Chat Icon For mobile
Up arrow icon