使 Flexs 3 DataGridColumn 的宽度适应其 ItemRenderer 的内容?
我有以下场景:
- Flex 3 DataGrid 坐在这里
- 在运行时,一列被添加到该网格
- 该列有一个自定义 ItemRenderer
- ItemRenderer 继承自 HBox,并动态添加一些项目到 HBOx
我的问题是宽度列的值不会改变。因此,我的列保持很小,并且行中显示丑陋的水平滚动条,而不是我的内容(完全不可读)。
我希望该列的宽度适应 ItemRenderer 中 HBox 的内容。我尝试了以下操作:
- 将 ItemRenderer 的“percentWidth”设置为“100”
- 添加项目后使 ItemRenderer 的属性无效
唯一具有“可见”效果的东西是强制 DataGridColumn 的宽度。显然这是不可接受的,因为我动态地将组件添加到 ItemRenderer,并且我不知道它们有多少或有多大。
此外,当我在 ItemRenderer 中时,我无法访问列本身(或者我可以吗?),因此我无法从此处强制设置列的大小。
那么有办法解决这个问题吗? AdvancedDataGrid 会在这里提供帮助吗(尽管事实上我因其他原因无法真正使用它......)
或者,如果有人有一个解决方案,其中显示列单元格而没有丑陋的水平滚动条(不要提及设置),我会很高兴将 HorizontalScrollPolicy 设置为“关闭”,去过那里,尝试过,但丢失了衬衫;))。
谢谢
PH
I have the following scenario :
- A Flex 3 DataGrid is sitting here
- At runtime, a column is added to this grid
- The column has a custom ItemRenderer
- The ItemRenderer inherits from HBox, and adds a few items to the HBOx dynamically
My problem is that the width of the column doesn't change. As a consequence, my column stays small, and an ugly horizontal scrollbar is displayed in the line, instead of my content (which is completely unreadable).
I would like the column to adapt its width to the content of the HBox in the ItemRenderer. I tried the following :
- Setting the 'percentWidth' of the ItemRenderer to '100'
- Invalidating the properties of the ItemRenderer after adding the items
The only thing that has a "visible" effect it to force the width of the DataGridColumn. Obviously this is not acceptable since I'm dynamically adding components to the ItemRenderer, and I don't know how many or how big they are.
Besides, when I am in the ItemRenderer, I have no access to the column itself (or do I ?) so I cannot force the size of the column from here.
So is there a way around this ? Would AdvancedDataGrid help here (notwhistanding the fact that I cannot really use it for other reasons ...)
Alternatively, I would be happy enough if someone has a solution where the column cell is displayed without the ugly horizontal scrollbar (don't mention setting horizontalScrollPolicy to "off", been there, tried that, lost shirt ;) ).
Thanks
PH
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有找到尺寸的解决方案,但是我找到了删除滚动条的方法;您必须将“horizontalScrollPolicy : 'off'”放入 itemRenderer Factory 的属性列表中(而不是放在 itemRenderer 本身上)。
I did not found a solution for the size, however I found the way to remove the scrollbar ; you must put the "horizontalScrollPolicy : 'off'" in the list of properties of the itemRenderer Factory (rather then on the itemRenderer itself).