Ext.GridPanel高度大于指定高度时垂直滚动,小于指定高度时自动适应

grid_taskQueryPop = new Ext.grid.GridPanel({ 
	        applyTo: 'search-panel',
	        title:'',
	        store: store_taskQueryPop,
	        cm: cm_taskQueryPop,
	        sm: query_sm, //new Ext.grid.RowSelectionModel({singleSelect:true}),
	        width: 500,
	        //autoHeight: true,
	        height: 290,	//10条记录时的行高;
	        //maxHeight: 290,
	        view: new Ext.grid.GridView({
				forceFit:true
			}),
	        tbar: [
	        	//' ',
	        	//{xtype: 'checkbox', boxLabel: '  ' + TagCharacterTask.SELECT_ALL, id: 'selectAll'},
	        	'     ',
	        	TagCharacterTask.SELECT_BY_NAME_COLON,
	            {xtype: 'textfield', id: 'queryConTextId'},
	            {xtype: 'button', text: TagCharacterTask.SALE_TASK_SEARCH, iconCls: 'searchTask', handler: searchCheckBox}
	        ],
	        bbar: new Ext.PagingToolbar({ 
		        pageSize: pageCount, 
		        store: store_taskQueryPop, 
		        displayInfo: true, 
		        displayMsg: CommonRes.BBAR_TEXT, 
		        emptyMsg: CommonRes.NO_RECORD
		    })
	    });

 

store_taskQueryPop.on("load", function(tis, records, opt){
	    	if(records.length < 10){//小于10行时自适应
	    		var frameHeight = grid_taskQueryPop.getFrameHeight();
	    		var innerHeight = grid_taskQueryPop.getEl().select('div.x-grid3-body');
	    		//alert(innerHeight.first().getHeight());
	    		grid_taskQueryPop.setHeight(innerHeight.first().getHeight() + frameHeight + 26);
	    		grid_taskQueryPop.syncSize();
	    	}
}
 

 

 

你可能感兴趣的:(ext)