动态更改FLEX中Datagrid列的宽度
我们是否可以通过点击列的边框来动态改变datagrid列的宽度,以便显示太长而无法显示且需要滚动的完整字符串? 如果是这样,怎么办?
另外,我们如何确保列宽根据字符数/字符串长度动态变化; 因为很多时候数据太长而无法显示。 在显示到数据网格之前,我们可以设置列宽以考虑数据的长度吗?
Can we change the width of the datagrid column dynamically by clicking on the border of the column in order to display the complete string which is too long to be displayed and needs to be scrolled ? If so, How ?
Also, how can we ensure that the column width changes dynamically based on the number of characters / length of string; since many a times the data is too long to be displayed. Can we set the column width to take the length of data into consideration before displaying onto the datagrid ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
所以我遇到了类似的问题,这就是我发现的。 如果设置:
那么列宽将自动调整大小以适合 DataGrid 的宽度。 您还可以手动设置列宽,只要将滚动设置为打开或关闭并且不设置为自动即可。 我发现了一篇关于此的有趣文章, http://junleashed .wordpress.com/2008/07/10/flex-datagridcolumn-width-management/。 基本上,他手动管理列宽,然后计算滚动条是否应该打开或关闭。
So I was having a similar problem and here is what I found. If you set:
Then the column widths will size automatically to fit the width of the DataGrid. You can also manually set the column widths, as long as scrolling is set to either on or off and not set to auto. I found an interesting article about this, http://junleashed.wordpress.com/2008/07/10/flex-datagridcolumn-width-management/. Basically, he manages the column widths manually, and then calculates whether the scrollbar should be on or off.
这是我想到的,但对于大型数据提供商来说可能效率不高:
This is what I came up with however it may not be efficient for large data providers:
我最近遇到了同样的问题,我发现的唯一解决方案是使用自定义函数来优化 DataGrid 的列宽度,如建议的 此处:
I recently encountered that same issue and the only solution I found is to use a customized function that optimizes the DataGrid's columns width as suggested here:
对于 Gridview 控件,您可以深入查看 SelectedRowStyle 属性并将 Wrap 设置为 True。
For the Gridview control, you can drill-down into the SelectedRowStyle property and set Wrap to True.