当 CollapsiblePanelExtender 折叠时调整 gridview 面板的大小

发布于 2024-12-13 18:48:49 字数 3498 浏览 1 评论 0原文

当 collapsiblepanelextender 折叠或展开时,我会触发以下 javascript。

function clickMe() {
  var collPanel = $find("CollapsiblePanelExtender2");
    if (collPanel.get_Collapsed()) {
        var H = "350px";
        var item = "Panel2";
        document.getElementById(item).height = H;
        //alert("c height: " + document.getElementById(item).height);
    }
    else {
        var H = "480px";
        var item = "Panel2";
        document.getElementById(item).height = H;
        //alert("not c height: " + document.getElementById(item).height);
    }

下面是当上面的面板折叠时我试图调整大小的面板。 gridview 没有发生任何事情 - 我的可折叠面板工作得很好 - 但是“Panel2”似乎没有调整大小???

<asp:Panel ID="Panel2" runat="server" CssClass="pClick" ScrollBars="Vertical">
                    <asp:GridView ID="GridView1" runat="server" AllowSorting="True"  
                        OnRowDataBound="GridView1_RowDataBound" CssClass="dataTable2"  Height="100%"
                        OnSorting="GridView1_Sorting" style="text-align: center" 
                        AutoGenerateColumns="False" RowStyle-VerticalAlign="Bottom"  RowStyle-Height="30px">
                        <AlternatingRowStyle BackColor="#D3F0F8"/>
                        <HeaderStyle CssClass="header"  Width="98.5%"/>

                        <Columns>
                            <asp:BoundField HeaderText="Name" DataField="Name" SortExpression="name" ItemStyle-Width="20%" HeaderStyle-Width="20%"></asp:BoundField>
                            <asp:BoundField HeaderText="Address" DataField="Address1" SortExpression="address" ItemStyle-Width="15%" HeaderStyle-Width="15%"></asp:BoundField>
                            <asp:BoundField HeaderText="City" DataField="City" SortExpression="City" ItemStyle-Width="15%" HeaderStyle-Width="15%"></asp:BoundField>
                            <asp:BoundField HeaderText="State" DataField="State" SortExpression="State" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Zip" DataField="Zip" SortExpression="zip" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Region" DataField="Region" SortExpression="region" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Sales Rep" DataField="SalesRep" SortExpression="salesrep" ItemStyle-Width="20%" HeaderStyle-Width="20%"></asp:BoundField>
                            <asp:BoundField HeaderText="Rating" DataField="Rating" SortExpression="rating" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Num Vehicles" DataField="NumberVehicles" SortExpression="numbervehicles" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="AdminId" DataField="AdminId" Visible="false"></asp:BoundField>
                            <asp:BoundField HeaderText="CrmId" DataField="CRMId" Visible="false"></asp:BoundField>
                            <asp:BoundField HeaderText="MasId" DataField="MasId" Visible="false"></asp:BoundField>
                        </Columns>
                    </asp:GridView>
                 </asp:Panel>

I have the following javascript firing when the collapsiblepanelextender is collapsed or expanded.

function clickMe() {
  var collPanel = $find("CollapsiblePanelExtender2");
    if (collPanel.get_Collapsed()) {
        var H = "350px";
        var item = "Panel2";
        document.getElementById(item).height = H;
        //alert("c height: " + document.getElementById(item).height);
    }
    else {
        var H = "480px";
        var item = "Panel2";
        document.getElementById(item).height = H;
        //alert("not c height: " + document.getElementById(item).height);
    }

below is the panel I am trying to resize when the panel above is collapsed. Nothing happens to the gridview - my colapsible panel works great - however 'Panel2' does not appear to resize ????

<asp:Panel ID="Panel2" runat="server" CssClass="pClick" ScrollBars="Vertical">
                    <asp:GridView ID="GridView1" runat="server" AllowSorting="True"  
                        OnRowDataBound="GridView1_RowDataBound" CssClass="dataTable2"  Height="100%"
                        OnSorting="GridView1_Sorting" style="text-align: center" 
                        AutoGenerateColumns="False" RowStyle-VerticalAlign="Bottom"  RowStyle-Height="30px">
                        <AlternatingRowStyle BackColor="#D3F0F8"/>
                        <HeaderStyle CssClass="header"  Width="98.5%"/>

                        <Columns>
                            <asp:BoundField HeaderText="Name" DataField="Name" SortExpression="name" ItemStyle-Width="20%" HeaderStyle-Width="20%"></asp:BoundField>
                            <asp:BoundField HeaderText="Address" DataField="Address1" SortExpression="address" ItemStyle-Width="15%" HeaderStyle-Width="15%"></asp:BoundField>
                            <asp:BoundField HeaderText="City" DataField="City" SortExpression="City" ItemStyle-Width="15%" HeaderStyle-Width="15%"></asp:BoundField>
                            <asp:BoundField HeaderText="State" DataField="State" SortExpression="State" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Zip" DataField="Zip" SortExpression="zip" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Region" DataField="Region" SortExpression="region" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Sales Rep" DataField="SalesRep" SortExpression="salesrep" ItemStyle-Width="20%" HeaderStyle-Width="20%"></asp:BoundField>
                            <asp:BoundField HeaderText="Rating" DataField="Rating" SortExpression="rating" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="Num Vehicles" DataField="NumberVehicles" SortExpression="numbervehicles" ItemStyle-Width="6%" HeaderStyle-Width="6%"></asp:BoundField>
                            <asp:BoundField HeaderText="AdminId" DataField="AdminId" Visible="false"></asp:BoundField>
                            <asp:BoundField HeaderText="CrmId" DataField="CRMId" Visible="false"></asp:BoundField>
                            <asp:BoundField HeaderText="MasId" DataField="MasId" Visible="false"></asp:BoundField>
                        </Columns>
                    </asp:GridView>
                 </asp:Panel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文