日期:2014-05-16 浏览次数:20324 次
ExtJS让页面最下面的panel自适应高度和宽度 getGridHeight = function(panelNameOne, panelNameTwo, panelThree) { //获取页面最下面的grid的高度,可以根据分辨率来自定义设置,根据项目需要估计在grid上面最多有三个panel //如果第二个和第三个panel没有传入值的话,需要传入'0'来补齐, //方法返回值就是你的grid的高度,如果根据分辨率返回值的值小于零,那么就会传出一个150的高度。 var gridHeight = ''; if (panelNameOne != '0' && panelNameTwo != '0' && panelThree == '0') { //表明页面有三个panel,需要的到第三个panel的高度 var tabPanelHeight = Ext.getCmp('MainTabPanel').getSize().height; var panel1Height = panelNameOne.getSize().height; var panel2Height = panelNameTwo.getSize().height; var gridHeight = tabPanelHeight - panel1Height - panel2Height - 31; } if (panelNameOne != '0' && panelNameTwo == '0' && panelThree == '0') { //表明页面有两个panel,需要的到第二个panel的高度 var tabPanelHeight = Ext.getCmp('MainTabPanel').getSize().height; var panelHeight = panelNameOne.getSize().height; var gridHeight = tabPanelHeight - panelHeight - 31; } if (panelNameOne != '0' && panelNameTwo != '0' && panelThree != '0') { //表明页面有四个panel,需要的到第四个panel的高度 var tabPanelHeight = Ext.getCmp('MainTabPanel').getSize().height; var panel1Height = panelNameOne.getSize().height; var panel2Height = panelNameTwo.getSize().height; var panel3Height = panelThree.getSize().height; var gridHeight = tabPanelHeight - panel1Height - panel2Height - panel3Height - 31; } if (panelNameTwo == '0' && panelThree == '0' && panelNameOne == '0') { //页面只有一个panel,需要得到第一个panel的高度 var tabPanelHeight = Ext.getCmp('MainTabPanel').getSize().height; var gridHeight = tabPanelHeight - 31; } if(parseInt(gridHeight)<0){ return 150; }else{ return gridHeight; } //自动适应宽的写法 //bodyStyle : 'width:99.8%' //autoWidth : true }