resize grids on browserwindow resize, see #10

This commit is contained in:
Sebastian Sdorra
2011-04-16 13:36:38 +02:00
parent 1b43ff2258
commit 5bff5bbd17
4 changed files with 80 additions and 4 deletions

View File

@@ -93,13 +93,32 @@ Sonia.group.Grid = Ext.extend(Sonia.rest.Grid, {
autoExpandColumn: 'members',
store: groupStore,
colModel: groupColModel,
emptyText: this.emptyGroupStoreText
emptyText: this.emptyGroupStoreText,
listeners: {
fallBelowMinHeight: {
fn: this.onFallBelowMinHeight,
scope: this
}
}
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.group.Grid.superclass.initComponent.apply(this, arguments);
},
onFallBelowMinHeight: function(height, minHeight){
var p = Ext.getCmp('groupEditPanel');
this.setHeight(minHeight);
var epHeight = p.getHeight();
p.setHeight(epHeight - (minHeight - height));
// rerender
this.doLayout();
p.doLayout();
this.ownerCt.doLayout();
},
renderMembers: function(members){
var out = '';
if ( members != null ){

View File

@@ -132,13 +132,30 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
autoExpandColumn: 'description',
store: repositoryStore,
colModel: repositoryColModel,
emptyText: this.emptyText
emptyText: this.emptyText,
listeners: {
fallBelowMinHeight: {
fn: this.onFallBelowMinHeight,
scope: this
}
}
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.repository.Grid.superclass.initComponent.apply(this, arguments);
},
onFallBelowMinHeight: function(height, minHeight){
var p = Ext.getCmp('repositoryEditPanel');
this.setHeight(minHeight);
var epHeight = p.getHeight();
p.setHeight(epHeight - (minHeight - height));
// rerender
this.doLayout();
p.doLayout();
this.ownerCt.doLayout();
},
selectItem: function(item){
if ( debug ){
console.debug( item.name + ' selected' );

View File

@@ -75,6 +75,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
mailtoTemplate: '<a href="mailto: {0}">{0}</a>',
checkboxTemplate: '<input type="checkbox" disabled="true" {0}/>',
emptyText: 'No items available',
minHeight: 150,
initComponent: function(){
@@ -90,7 +91,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
});
var config = {
minHeight: 150,
minHeight: this.minHeight,
loadMask: true,
sm: selectionModel,
viewConfig: {
@@ -99,6 +100,10 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
}
};
this.addEvents('fallBelowMinHeight');
Ext.EventManager.onWindowResize(this.resize, this);
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.rest.Grid.superclass.initComponent.apply(this, arguments);
@@ -109,6 +114,24 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
this.store.load();
},
resize: function(){
var h = this.getHeight();
if (debug){
console.debug('' + h + ' < ' + this.minHeight + " = " + (h < this.minHeight));
}
if ( h < this.minHeight ){
if ( debug ){
console.debug( 'fire event fallBelowMinHeight' );
}
this.fireEvent('fallBelowMinHeight', h, this.minHeight);
}
},
onDestroy: function(){
Ext.EventManager.removeResizeListener(this.resize, this);
Sonia.rest.Grid.superclass.onDestroy.apply(this, arguments);
},
reload: function(){
if ( debug ){
console.debug('reload store');

View File

@@ -99,13 +99,30 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
var config = {
store: userStore,
colModel: userColModel
colModel: userColModel,
listeners: {
fallBelowMinHeight: {
fn: this.onFallBelowMinHeight,
scope: this
}
}
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.user.Grid.superclass.initComponent.apply(this, arguments);
},
onFallBelowMinHeight: function(height, minHeight){
var p = Ext.getCmp('userEditPanel');
this.setHeight(minHeight);
var epHeight = p.getHeight();
p.setHeight(epHeight - (minHeight - height));
// rerender
this.doLayout();
p.doLayout();
this.ownerCt.doLayout();
},
selectItem: function(item){
if ( debug ){
console.debug( item.name + ' selected' );