在ExtJ6.2中,有一个Sencha论坛中描述的bug。
因为6.2+ Ext.grid.Panel在使用列项时忽略flex。 重现问题的步骤:在6.2+中创建一个网格,添加没有条目的列和flex:1 klick,在小提琴中运行,并且看起来很好,将一个条目添加到使用flex:1! 预期的结果是:我希望该列能够灵活使用。 所发生的结果:该列将以最小大小呈现。
线程说在夜间构建中可以纠正这一点,但是ExtJs6.2.1还不能在GPL版本中使用。这个问题有什么解决办法吗?
或者是否有人可以发布带有错误修复的覆盖?
编辑:其他洞察力
查看绑定到列和网格的事件,我可以断言bug发生在afterrender事件(column.flex = 1)和afterlayout事件(column.flex = null)之间。我不太了解ExtJ的布局运行细节,所以我对如何进一步缩小违规代码可能被定位的范围缺乏想法。如果有人能给出这个方向的提示,而不是一个完整的答案,他们也是受欢迎的。
发布于 2018-08-15 12:50:07
有一个更简单的解决办法(根据https://fiddle.sencha.com/#view/editor&fiddle/2kgh):
只需在其子项中复制列的flex属性即可。
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name', flex: 1,
items: [
{
xtype: 'textfield',
flex: 1
}
]
},发布于 2017-02-07 14:34:57
我找到了一种解决方法,一旦网格布局好,就可以调整列的大小。这是它应该做的。
唯一的缺点是它将列放置了两次。
Ext.define('App.override.grid.Panel', {
override: 'Ext.grid.Panel',
initComponent: function() {
this.callParent(arguments);
this.on('afterlayout', this.resizeColumns);
},
resizeColumns: function () {
var me = this,
width = this.getWidth(),
flex = 0;
Ext.batchLayouts(function(){
me.columns.each(function (col) {
if (col.config.flex) flex += col.config.flex
else if (col.config.width) width -= col.config.width
else width -= col.getWidth()
})
if (flex) {
me.columns.each(function (col) {
if (col.config.flex) {
newWidth = Math.round(width * col.config.flex / flex)
if (col.getWidth() != newWidth) col.setWidth(newWidth)
}
})
}
})
}
})问题:以这种方式设置宽度的列不再是用户可调整大小的。
https://stackoverflow.com/questions/42064892
复制相似问题