tabPanel中的GridPanel宽度,高度自适应

//定义在脚本中使用的层id变量
var mainName = "<%=mainName%>";

Ext.onReady(function() {
			var proxy = new Ext.data.HttpProxy({
						url : '../StudentDispatchAction.do?method=queryCourse',
						method : 'GET'
					});

			var reader = new Ext.data.JsonReader({
						root : 'Data',
						totalProperty : 'TotolRecord'
					}, [{
								name : 'term'
							}, {
								name : 'teachId'
							}, {
								name : 'couName'
							}, {
								name : 'couCredit'
							}, {
								name : 'couType'
							}, {
								name : 'scMark'
							}, {
								name : 'scMakeup'
							} 
							]);

			var store = new Ext.data.Store({
						proxy : proxy,
						reader : reader
					});

			// create the Grid
			var grid = new Ext.grid.GridPanel({
						store : store,
						columns : [new Ext.grid.RowNumberer(), {
									id : 'term',
									header : "学年学期",
									width : 30,
									sortable : true,
									dataIndex : 'term'
								}, {
									header : "开课编号",
									width : 75,
									sortable : true,
									dataIndex : 'teachId'
								}, {
									header : "课程名称",
									width : 75,
									sortable : true,
									dataIndex : 'couName'
								}, {
									header : "学分",
									width : 75,
									sortable : true,
									dataIndex : 'couCredit'
								}, {
									header : "课程类型",
									width : 75,
									sortable : true,
									dataIndex : 'couType'
								}, {
									header : "考试成绩",
									width : 75,
									sortable : true,
									dataIndex : 'scMark'
								}, {
									header : "补考成绩",
									width : 75,
									sortable : true,
									dataIndex : 'scMakeup'
								}],
						stripeRows : true,
						autoExpandColumn : 'teachId',
						height : Ext.get("center").getHeight() - 50,
						bodyStyle : 'width:100%',
						autoWidth : true,
						autoScroll : true,
						// title: '我的开课',
						id : 'Course',
						viewConfig : {
							forceFit : true
						},
						bbar : new Ext.PagingToolbar({
									pageSize : 10,// 每页显示的记录值
									store : store,
									displayInfo : true,
									displayMsg : '总记录数 {0} - {1} of {2}',
									emptyMsg : "没有记录"
								})
					});

			grid.render(mainName);
			store.load({
						params : {
							start : 0,
							limit : 10
						}
					});
			grid.getSelectionModel().selectFirstRow();
		});
		
function ComResize(){ 
	 var h = Ext.get("center").getHeight() - 30;	//center为我的tab子面板动态add直去的面板
	// 获取面板
	var centerpanel = Ext.getCmp("Course");	//Course即为我当前页面显示的表格
	if (centerpanel) {
		centerpanel.setHeight(h);
	}
}
//通过window.onresize事件来执行allComResize函数控制tab容器的大小 
var oTime; 
window.onresize = function() {	
 if (oTime) 
    { 
        clearTimeout(oTime); 
    } 
    oTime = setTimeout("ComResize()", 100); //延迟100毫秒执行 


};

 注意:IE在执行的时候会有问题,窗口变化,但获取的高度却先于变化,导致高度没变化。故设置延时执行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值