如何折叠和扩展devexpress master / detail asp.net gridview

时间:2012-03-14 17:08:52

标签: asp.net gridview devexpress

我在主/详细配置中有两个asp.net devexpress网格视图。我展开一个主行来显示子行,并对子行进行操作,如编辑,添加新行和删除行。之后,我希望父网格视图折叠,并且两个网格视图都要刷新新数据。请让我知道我该怎么做。在devexpress网站上,我看到提到了CollapseRow和ExpandRow javascript客户端方法。但找不到任何描述如何调用它们的示例代码。

由于

1 个答案:

答案 0 :(得分:2)

首先将clientInstanceName分配给网格:

<dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="ID" 
            ClientInstanceName="grid">

完成更新或删除后,如您在完成操作后调用grid.CollapseAllDetailRows();所述。或在ASPxClientGridView.DetailRowExpanding Event上设置展开的详细信息行visibleindex。根据您的要求检查以下代码段和代码。

<html>
     <head runat="server">
    <title></title>
    <script language ="javascript" type ="text/javascript">
        var focusedIndex;
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <dx:ASPxGridView ID="ASPxGridView1" runat="server" KeyFieldName="ID" ClientInstanceName="grid">
            <ClientSideEvents DetailRowExpanding="function(s, e) {
    focusedIndex = e.visibleIndex;
}" />
            <SettingsBehavior AllowFocusedRow="True" AllowSelectByRowClick = "true" />
            <SettingsDetail ShowDetailRow="True" />
        </dx:ASPxGridView>
        <dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="ASPxButton">
            <ClientSideEvents Click="function(s, e) {
            //var visibleindex =    grid.GetFocusedRowIndex();
            //grid.CollapseAllDetailRows();
            if( focusedIndex  != 'undefined')
            {
            grid.CollapseDetailRow(focusedIndex );
            }
            }"/>
        </dx:ASPxButton>
    </div>
    </form>
</body>
</html>