【问题标题】:Resize columns of a ASP.NET Gridview beyond its data length调整 ASP.NET Gridview 的列大小超出其数据长度
【发布时间】:2013-09-27 06:43:16
【问题描述】:

我有一个包含网格视图的网页,并希望为其列添加调整大小功能。我设法使用 javascript 来做到这一点,但无法将列的大小减小到超出该列的最大数据长度。似乎 gridview 的某些属性阻止了它们的列宽被缩小到超过最大数据长度。

我尝试使用诸如

之类的样式
text-overflow: ellipsis;
overflow:hidden;
white-space:nowrap;

但无法完成,因为这些仅在更改列大小后处理数据的表示。有人可以给我一些指导吗? 非常感谢。

这是部分代码...

<asp:MultiView ID="uxMainMultiView" runat="server" ActiveViewIndex="0">
<asp:View ID="uxHistoryView" runat="server">
    <asp:MultiView ID="uxCaseSearchResultMultiView" runat="server" ActiveViewIndex="0">
        <asp:View ID="uxFlatView" runat="server">
            <asp:GridView ID="uxCaseSearchGrid" runat="server" BorderWidth="0px" CssClass="grid"
                Width="100%" OnInit="uxCaseSearchGrid_Init" OnRowDataBound="uxCaseSearchGrid_RowDataBound"
                AllowPaging="true" AllowSorting="true" OnPageIndexChanging="uxCaseSearchGridPageIndexChanging"
                OnSorting="uxCaseSearchGridViewSorting" OnDataBound="uxCaseSearchGrid_DataBound" AutoGenerateColumns="true">

                <RowStyle CssClass="gridRowLarge" />
                <AlternatingRowStyle CssClass="gridAltRowLarge" />
                <HeaderStyle CssClass="gridHeaderLarge noLink" />
            </asp:GridView>

【问题讨论】:

  • 您是否尝试查看所有 CSS 都应用于该列?

标签: c# javascript asp.net css


【解决方案1】:

如何在你的 CSS 中添加一个 min-width 属性:

min-width:0;

允许在运行时调整列单元格的大小。

【讨论】:

  • 它没有工作的朋友:(如果你知道任何其他风格请发帖。
  • 你能分享你为gridview渲染的html吗?
  • 我添加了一些。感谢 Sunny 的宝贵时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-25
  • 1970-01-01
  • 2021-12-11
  • 2011-05-07
  • 2015-08-28
  • 2023-03-29
相关资源
最近更新 更多