如何:自动调整 GridPanel 列宽度 +读取 Ext JS4 网格中的所有列值
如何:自动调整 GridPanel 列宽 + 读取 Ext JS4 中网格中的所有列值
问题 1:我是否可以自动设置 gridpanel 列宽, 基于重新调整的列数据值长度(列宽 = 最大数据值 字符串长度)
问题2:为了实现上述目标(以及其他原因),我需要知道如何获取值 特定的网格列?一旦我知道了逻辑,就应该将其实现为列 渲染器功能?每次都会调用列渲染器函数,一个数据 记录被读取(那么它的杀伤力)?,在这种情况下,还有其他我可以重写的函数吗?
大多数解决方案(网格列宽计算器, autoResizeColumns等)我在网上找到的是以前的版本,我使用的是EXTJS 4版本。
提前致谢 斯科特
How To: Auto Resize GridPanel Column Width + Read all Column Values in a Grid in Ext JS4
Problem 1: Is there anyway I can automatically set gridpanel column width,
based on retruned column data values length (column width = max data value
string length)
Problem 2: To achive above (and for other reasons), I need to know how i can get values of
particular grid column? Once i know the logic, should implement it as column
renderer function? Would column renderer function is called every time, a data
record is read (then its overkill)?, in that case is there any other function I can override?
Most of the solutions (Grid Column Width Calculator,
autoResizeColumns,etc) I find on the web are for previous versions, am using EXTJS 4 version.
Thanks in advance
Scott
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上有一个 Extjs 4 插件可以根据内容和标题的宽度自动调整网格列的大小。
这是链接:Extjs 4列自动调整大小插件
There is actually an Extjs 4 plugin to automatically resize grid columns based on the width of the contents as well as the header.
Here is the link: Extjs 4 column auto resize plugin
不幸的是,没有。最好的选择是为通常固定的数据设置指定的宽度,然后使用
flex
设置其他列。 (或编写/等待插件)。值不存储在
网格
中,而是存储在网格
的存储
中。您只需要循环相关的store
并从指定列中获取所有值。例如:Unfortunately, no. Your best bet would be to set specified widths for data that was generally fixed, and then set the other columns using
flex
. (or write / wait for a plugin).Values are not stored in the
grid
, they are in thegrid
'sstore
. You would simply need to loop thestore
in question and grab all the values from the specified column. For example:我找到了使用 CSS 包装列的临时修复,如下所述:
ExtJS 4 - 在网格面板中包裹列标题
将以下内容添加到 ext js css
I have found a temporary fix to wrap Columns using CSS, as described here:
ExtJS 4 - Wrapping the column headers in grid panel
Add the following to ext js css