简体   繁体   English

如何限制列的宽度并使其文本换行

[英]How to limit the width of a column and make its text wrap

I have a RadGrid in my application and whats happening is that if the text in the column of the grid is to long it will not wrap so the grid container will expand and get out of the frame so I would like to make it so that when the text in the column is too long that it wraps, how can I do this? 我的应用程序中有一个RadGrid,发生的事情是,如果网格列中的文本很长,它将不会换行,因此网格容器将展开并离开框架,所以我想这样做,以便列中的文本太长,无法包装,我该怎么办? Here is an example of one of those columns. 以下是其中一列的示例。

 <telerik:GridBoundColumn DataField="clientnum" 
 HeaderText="Client Number" HeaderStyle-HorizontalAlign="Left" 
 AllowSorting="false" />

Thank you for your help 谢谢您的帮助

Try the following aspx code . 尝试以下aspx代码。

ASPX: ASPX:

<MasterTableView   > 
<ItemStyle   Wrap="True" /> 

Set the width of column to a fixed width, so it will wrap the text after crossing the limits 将列的宽度设置为固定宽度,因此它将在超过限制后包装文本

I think, the best way is to see id of your generated table by firebug and then you can set up width via css. 我想,最好的方法是通过firebug查看生成的表的id,然后你可以通过css设置宽度。 In css file you should write something like this 在css文件中你应该写这样的东西

#table_id td{
 width: 50px;/*for example*/
}

have you tried adding in the HeaderStyle-Width tag? 你有没有尝试添加HeaderStyle-Width标签? So like this: 像这样:

    <telerik:GridBoundColumn DataField="clientnum" 
    HeaderText="Client Number" HeaderStyle-HorizontalAlign="Left" 
    AllowSorting="false" HeaderStyle-Width="100"/>

Where you replace 100 with the width you want. 在哪里用你想要的宽度替换100。

Let me know if it works! 如果有效,请告诉我!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM