admin管理员组文章数量:1420112
emphasized textWhen columns' width in panel.Grid
is set using the width
property columns resize by grid.columns[index].setWidth(width)
works as it should. But when columns' width is set by flex
, this code doesn't work.
Just to make it clear: I'm trying to synchronize columns resize/move/hide/etc events on two grids.
So both grids have basically the same columns:
me.columns = {
defaults: {
renderer: tooltipRenderer
},
items: [
{
header: "product",
dataIndex: 'product',
groupable: false,
flex: 1
},
{
header:'Value',
dataIndex: 'vlue',
align: 'right',
renderer: Ext.util.Format.numberRenderer('0,000.00'),
summaryType: 'remote',
summaryRenderer: Ext.util.Format.numberRenderer('0,000.00'),
groupable: false,
flex: 1
}
]
};
Code from plugin to synchronize columns resize:
firstGrid.on('columnresize', function (ct, column, width) {
console.log('fgrid: ' + width + ' column name: ' + column.dataIndex);
secondGrid.columns[column.getIndex()].setWidth(width);
}, firstGrid);
secondGrid.on('columnresize', function (ct, column, width) {
console.log('sGrid: ' + width + ' column name: ' + column.dataIndex);
firstGrid.columns[column.getIndex()].setWidth(width);
}, secondGrid);
So, what I have now: when I resize columns with width set by flex
in one grid corresponding column from the other doesn't change it's width, but if after resizing column in one grid I resize one from the other everything works just as it should.
I hope this description wasn't too weird.
emphasized textWhen columns' width in panel.Grid
is set using the width
property columns resize by grid.columns[index].setWidth(width)
works as it should. But when columns' width is set by flex
, this code doesn't work.
Just to make it clear: I'm trying to synchronize columns resize/move/hide/etc events on two grids.
So both grids have basically the same columns:
me.columns = {
defaults: {
renderer: tooltipRenderer
},
items: [
{
header: "product",
dataIndex: 'product',
groupable: false,
flex: 1
},
{
header:'Value',
dataIndex: 'vlue',
align: 'right',
renderer: Ext.util.Format.numberRenderer('0,000.00'),
summaryType: 'remote',
summaryRenderer: Ext.util.Format.numberRenderer('0,000.00'),
groupable: false,
flex: 1
}
]
};
Code from plugin to synchronize columns resize:
firstGrid.on('columnresize', function (ct, column, width) {
console.log('fgrid: ' + width + ' column name: ' + column.dataIndex);
secondGrid.columns[column.getIndex()].setWidth(width);
}, firstGrid);
secondGrid.on('columnresize', function (ct, column, width) {
console.log('sGrid: ' + width + ' column name: ' + column.dataIndex);
firstGrid.columns[column.getIndex()].setWidth(width);
}, secondGrid);
So, what I have now: when I resize columns with width set by flex
in one grid corresponding column from the other doesn't change it's width, but if after resizing column in one grid I resize one from the other everything works just as it should.
I hope this description wasn't too weird.
- Have some code that we can play with? I can tell what you're asking, and have a few thoughts, but can't take the time if I have to write the start up (broken) code myself. – Ruan Mendes Commented Mar 18, 2014 at 15:45
- Sure. I'll post it in five minutes. – edthehead Commented Mar 18, 2014 at 15:57
1 Answer
Reset to default 4You're not supposed to set width on something where its width is being managed by a layout. If you delete the flex
property for the column, then setWidth
works
https://fiddle.sencha./#fiddle/4b4
My example toggles the flex property so you can set width, try clicking on the page and you'll see the flexed column change width
// Assume you have a variable gridwhere the second column is flexed.
Ext.getBody().on('click', function() {
var emailCol = grid.query('gridcolumn')[1];
if (emailCol.flex) {
delete emailCol.flex;
emailCol.setWidth(100);
} else {
emailCol.flex = 1;
grid.doLayout();
}
});
本文标签:
版权声明:本文标题:javascript - How to resize columns using grid.columns[index].setWidth(width) in ExtJS 4 when flex is applied? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745317953a2653239.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论