当我隐藏内部有图像的列时,网格行不会改变高度
扩展JS 4.0.2。我有网格,每行都有显示图像的列(100x100)。当网格渲染时,每行的高度约为 120px。当我隐藏带有图像的列时,我想更改行的高度,以便它们的高度像一个文本行。怎么做呢?我查看了 http: //docs.sencha.com/ext-js/4-0/#/api/Ext.grid.column.Column-cfg-hideMode 但它没有达到我想要的效果。
已更新 代码:
Ext.onReady(function() {
var myData = [
['3m Co','logo-small.png'],
['Alcoa Inc','logo-small.png'],
['Altria Group Inc','logo-small.png']
];
// create the data store
var store = Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'company'},
'url'
],
data: myData
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
{
text : 'Company',
flex : 1,
dataIndex: 'company'
} ,
{
text : 'Image',
width: 200,
hidden: true,
hideMode: 'display',
renderer : function(value){
return '<img src="'+value+'">';
},
dataIndex: 'url'
}
],
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
}); });
当隐藏列时,每行仍然有足够的高度来显示图像,我希望它们具有像没有图像列一样的高度
Ext.onReady(function() {
var myData = [
['3m Co','logo-small.png'],
['Alcoa Inc','logo-small.png'],
['Altria Group Inc','logo-small.png']
];
// create the data store
var store = Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'company'},
'url'
],
data: myData
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
{
text : 'Company',
flex : 1,
dataIndex: 'company'
}
],
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
}); });
Ext JS 4.0.2. I have grid, and every row has column which display image (100x100). When grid is rendered every row has height about 120px. When i hide column with image inside i want to change height of rows so they have height like a one text line. How to do it? I looked at http://docs.sencha.com/ext-js/4-0/#/api/Ext.grid.column.Column-cfg-hideMode but it doesn't do what i want.
updated
code:
Ext.onReady(function() {
var myData = [
['3m Co','logo-small.png'],
['Alcoa Inc','logo-small.png'],
['Altria Group Inc','logo-small.png']
];
// create the data store
var store = Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'company'},
'url'
],
data: myData
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
{
text : 'Company',
flex : 1,
dataIndex: 'company'
} ,
{
text : 'Image',
width: 200,
hidden: true,
hideMode: 'display',
renderer : function(value){
return '<img src="'+value+'">';
},
dataIndex: 'url'
}
],
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
}); });
when column is hidden each row has still enough height to display image, i want them to have height like there is no image column
Ext.onReady(function() {
var myData = [
['3m Co','logo-small.png'],
['Alcoa Inc','logo-small.png'],
['Altria Group Inc','logo-small.png']
];
// create the data store
var store = Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'company'},
'url'
],
data: myData
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
{
text : 'Company',
flex : 1,
dataIndex: 'company'
}
],
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
}); });
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题相当老了,但我认为我的回答可能会对某人有所帮助。
因为 ExtJS 没有提供直接与网格中的行进行通信的方法,所以我尝试查询行,然后修改 DOM。
当然,显示图像列时将应用相反的情况。
The question is rather old, but I think my answer may help someone.
Because ExtJS does not provide a way to directly communicate with the rows in grid, I try querying the rows, then modifying the DOM.
And of course the reverse will be applied when showing the image column.