Reputation: 10362
I have a problem with adding scrollbar to grid, that is inside of vbox container. I can not assign height directly, because I do not know it. In that vbox container also is 'another content' with undefined height, so I can not use neither 'height', neither 'flex'. I need to make grid fill all remaining space in the page, and if there will be more rows than it could fit - i need to add scrollbar to that grid. This is most important part of code:
{
layout: {
type: 'vbox',
align: 'stretch'
},
items:[
{
title: 'center'
},{
html: 'another content'
},{
xtype: 'grid',
autoScroll: true, // <-- this is not working
columns: [
{ text: 'User', dataIndex: 'userId' }
],
store: new Ext.data.Store({
model: 'Ext.data.Record',
fields: [
{ name: 'userId', type: 'string' }
],
data: ( function(){
var res = []
for(var i=0; i<1000; i++){
res.push({ userId: 'User'+i});
}
return res;
})()
})
}
]
}
I tryed a lot of variants, but no success.
I also prepere some fiddles for most logical solutions(but scroll is not working there anyway):
https://fiddle.sencha.com/#fiddle/fmo
https://fiddle.sencha.com/#fiddle/fmp
Any help will be good.
Upvotes: 2
Views: 6242
Reputation: 16466
Just remove autoScroll: true
and replace it with flex: 1
.
https://fiddle.sencha.com/#fiddle/fms
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.create('Ext.container.Viewport', {
renderTo: Ext.getBody(),
layout: {
type: 'border'
},
items: [
{
width: '100%',
region: 'north',
items: [{
title: 'north'
},{
html: 'another content'
}]
},
{
region: 'center',
layout: 'fit',
items: [{
layout: {
type: 'vbox',
align: 'stretch'
},
items:[
{
title: 'center'
},{
html: 'another content'
},{
xtype: 'grid',
flex: 1,
columns: [
{ text: 'User', dataIndex: 'userId' }
],
store: new Ext.data.Store({
model: 'Ext.data.Record',
fields: [
{ name: 'userId', type: 'string' }
],
data: ( function(){
var res = []
for(var i=0; i<1000; i++){
res.push({ userId: 'User'+i});
}
return res;
})()
})
}
]
}
]
}]
});
}
});
Upvotes: 6