0

我在此处的文档中阅读了有关弹出菜单的信息。我不清楚这个菜单是否已经提供,我们只需要启用一个特定的属性就可以了?或者它只是一个弹出菜单的示例并且需要创建?我刚刚开始探索 devexpress 网格,任何帮助将不胜感激。

4

2 回答 2

2

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

ASPxGridView - 如何以类似于 ASPxPivotGrid 的方式实现显示/隐藏列

例子。

于 2012-05-16T20:30:00.683 回答
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");
                }


        }
于 2012-06-28T13:01:09.920 回答