1

我正在使用 Telerik radgrid。我想展开当前正在编辑的项目以显示详细信息。我创建了一个在 OnCommand 事件发生时触发的函数。发生的事情是细节扩展,然后再次收缩!无论我如何为主数据项或详细信息设置 HierarchyLoadMode,我已经尝试了所有我能想到的设置,当主数据项进入编辑模式时,它仍然不会保持展开状态。

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Users.aspx.cs" Inherits="WebCallManagerData.Account.Users" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        function OnCommand(sender, args)
        {

            if (args.get_commandName() == 'Edit')
            {
                rowIndex = args.get_commandArgument();
                var radGrid = $find("<%= rgUsers.ClientID %>");
                var dataItem = radGrid.get_masterTableView().get_dataItems()[rowIndex];
                dataItem.set_expanded(true);

            }
            else if (args.get_commandName() == 'ExpandCollapse')
            {
                //dumpObject(args);
            }

        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Label ForeColor="Red" Text="" ID="DisplayMessage1" runat="server" />
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgUsers">
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadGrid ID="rgUsers" runat="server" CellSpacing="0" DataSourceID="odsUsers"
        GridLines="None" AutoGenerateColumns="False">
        <ClientSettings>
            <ClientEvents OnCommand="OnCommand" />
            <Selecting CellSelectionMode="None"></Selecting>
        </ClientSettings>
        <MasterTableView DataSourceID="odsUsers" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
            AllowAutomaticUpdates="True" DataKeyNames="UserName" HierarchyLoadMode="Client">
            <DetailTables>
                <telerik:GridTableView runat="server" DataSourceID="odsUserRole" AllowAutomaticUpdates="True"
                    AutoGenerateColumns="True" EditMode="EditForms" HierarchyLoadMode="Client">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="UserName" MasterKeyField="UserName" />
                    </ParentTableRelation>
                    <CommandItemSettings ExportToPdfText="Export to PDF" />
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
                        </telerik:GridEditCommandColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column" UniqueName="EditCommandColumn1">
                        </EditColumn>
                    </EditFormSettings>
                </telerik:GridTableView>
            </DetailTables>
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="UserName" FilterControlAltText="Filter UserName column"
                    HeaderText="UserName" SortExpression="UserName" UniqueName="UserName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Email" FilterControlAltText="Filter Email column"
                    HeaderText="Email" SortExpression="Email" UniqueName="Email">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="Approved" DataType="System.Boolean" FilterControlAltText="Filter Approved column"
                    HeaderText="Approved" SortExpression="Approved" UniqueName="Approved">
                </telerik:GridCheckBoxColumn>
                <telerik:GridCheckBoxColumn DataField="LockedOut" DataType="System.Boolean" FilterControlAltText="Filter LockedOut column"
                    HeaderText="LockedOut" SortExpression="LockedOut" UniqueName="LockedOut">
                </telerik:GridCheckBoxColumn>
                <telerik:GridBoundColumn DataField="Creation" FilterControlAltText="Filter Creation column"
                    HeaderText="Creation" SortExpression="Creation" UniqueName="Creation" DataType="System.DateTime">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastLogin" DataType="System.DateTime" FilterControlAltText="Filter LastLogin column"
                    HeaderText="LastLogin" SortExpression="LastLogin" UniqueName="LastLogin">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastActivity" DataType="System.DateTime" FilterControlAltText="Filter LastActivity column"
                    HeaderText="LastActivity" SortExpression="LastActivity" UniqueName="LastActivity">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastPasswordChanged" DataType="System.DateTime"
                    FilterControlAltText="Filter LastPasswordChanged column" HeaderText="LastPasswordChanged"
                    SortExpression="LastPasswordChanged" UniqueName="LastPasswordChanged">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="Online" DataType="System.Boolean" FilterControlAltText="Filter Online column"
                    HeaderText="Online" SortExpression="Online" UniqueName="Online">
                </telerik:GridCheckBoxColumn>
                <telerik:GridBoundColumn DataField="Password" FilterControlAltText="Filter Password column"
                    HeaderText="Password" SortExpression="Password" UniqueName="Password">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="odsUserRole" runat="server" SelectMethod="GetUserRoles"
        TypeName="WebCallManagerData.Account.MemberShipHelper.User" OldValuesParameterFormatString="original_{0}"
        UpdateMethod="UpdateUserRoles">
        <SelectParameters>
            <asp:Parameter DefaultValue="" Name="UserName" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ur" Type="Object" />
            <asp:Parameter Name="UserName" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsUsers" runat="server" SelectMethod="GetAllUsers" TypeName="WebCallManagerData.Account.MemberShipHelper.User">
    </asp:ObjectDataSource>
</asp:Content>
4

0 回答 0