ExtJS 网格列:展开列以显示完整内容
我创建了一个具有固定宽度的列的网格。 由于宽度固定,某些列无法扩展至足以显示完整内容,至少对于某些单元格而言是如此。
现在我正在寻找一种在双击标题时展开此列的方法。
我注意到 ColumnModel 中有一个函数 setColumnWidth() ,但要继续执行此操作,我必须获取内容的最大长度。
有人有什么建议吗?提前致谢!
I created a grid having columns with fixed width.
Due to the fixed width, some columns are not expanded enough to show full content, at least for some cells.
Now I am looking for a way to expand this column when double clicks at its header.
I noticed there is a function setColumnWidth() in ColumnModel, but to proceed this I have to get the maximum length of the content.
anybody has some advice? thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定是否将专栏扩展到内容的长度,这可能是一件好事。异常多的内容最终可能会使网格看起来很糟糕。但是,您可以将 Flex 添加到要扩展的任何列。
在该位中,Foo 列将扩展以占用 Blah 被分配为 100px 后留下的剩余空间。
Not sure about expanding the column to the length of the content, and that may be a good thing. An unusually long amount of content may end up making the grid look awful. However, you could add a flex to any column you want to expand.
In that bit, the Foo column will expand to take the remaining space left behind after Blah was allotted it's 100px.
知道这是一个旧线程,但我想分享它,因为我遇到了同样的问题。
我通过重写 Ext.grid.column.Column 的单击事件处理程序解决了这个问题。有一个私有的 onElDblClick 事件,用于双击列标题的边缘。
重写此函数还可以处理整个列标题上的双击。
接下来是重写 onElClick 事件处理程序,让它知道可能有一个通过 SetTimeout 调用挂起的双击操作,否则将始终调用附加到单击事件的任何事件(例如排序和下拉菜单)。
请参阅下面的代码来覆盖它。我只在 ExtJS 4.1.1a 上测试过它,但可以轻松移植到其他 ExtJS 版本。
双击检查是我在https://stackoverflow.com/a/16033129/3436982找到的改编版本。
Knowing this is an old thread, but I would like to share it as I had the same issue.
I solved it through overriding the click event handlers of Ext.grid.column.Column. There is a private onElDblClick event handled for double clicking on the edge of the column header.
Override this function to also handle double click on the entire column header.
Next is to override the onElClick event handler to let it know there could be a double click action pending via a SetTimeout call, otherwise any events attached to the single click event like sorting and the pull down menu will be called always.
See the below code to override it. I only tested it on ExtJS 4.1.1a, but would be easily ported to other ExtJS versions.
The double click check is an adapted version I found here https://stackoverflow.com/a/16033129/3436982.