显示AspxGridView的列标题的上下文菜单

时间:2012-05-16 20:20:51

标签: asp.net devexpress contextmenu aspxgridview

我在 documentation here 中阅读了有关弹出式菜单的信息。我不清楚这个菜单是否已经提供,我们只需启用特定属性使其可用?或者它只是一个弹出菜单的例子,需要创建?我刚开始探索devexpress网格,任何帮助都会受到赞赏。

2 个答案:

答案 0 :(得分:2)

本主题致力于XtraGrid - Winforms网格。 ASPxGridView不提供此菜单,您可以尝试自己实现它,如

中所示

ASPxGridView - How to implement showing/hiding columns in the manner similar to ASPxPivotGrid

例如

答案 1 :(得分:0)

It is possible we can create context menu on aspxgridview. Find the following example for aspxgridview context menu.



Default.aspx:
=============


<dx:ASPxGridView ID="grvContexMenuExample" runat="server" AutoGenerateColumns="false"
    KeyFieldName="ID" EnableViewState="true" ClientInstanceName="grdtest" Width="100%"
    Settings-GridLines="None" OnHtmlRowPrepared="grvContexMenuExample_HtmlRowPrepared">
    <ClientSideEvents ContextMenu="function(s,e) {
                                                       if(e.objectType == 'header')
                                                        {
                                                               headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
                                                         }
                                                         else if(e.objectType == 'row')
                                                         {
                                                             headerContextMenu.ShowAtPos(e.htmlEvent.clientX, e.htmlEvent.clientY);
                                                         }
                                                    }" />
    <Columns>

    <%--Your columns goes here--%>
        <columns>
</dx:ASPxGridView>

<!--Start New  Context Menu !-->
<dx:ASPxPopupMenu ID="mnContextMenu" runat="server" ClientInstanceName="headerContextMenu"
    EnableAnimation="false" PopupHorizontalAlign="OutsideRight" PopupVerticalAlign="TopSides"
    PopupAction="RightMouseClick">
    <Items>
        <dx:MenuItem Text="New Context Menu1">
        </dx:MenuItem>
    </Items>
    <ClientSideEvents ItemClick="ContextMenuItemClick" />
</dx:ASPxPopupMenu>
<!--End New   Context Menu !-->







Default.aspx.cs:
================

  protected void grvContexMenuExample_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
        {


            if (e.RowType == GridViewRowType.Data)

                if (e.RowType == GridViewRowType.Header)
                {

                    e.Row.Attributes.Remove("oncontextmenu");
                }


        }