Gridpanel & window resizing - Ext JS

本文探讨了ExtJS中GridPanel组件在浏览器窗口大小变化时的自适应问题。作者详细描述了GridPanel配置和使用过程,并指出在浏览器窗口调整大小时,GridPanel未能正确调整其宽度以匹配新的窗口尺寸。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ok, I've searched the forum over and over and can't seem to figure this out so I have to ask. Is the GridPanel not supposed to handle resizing of a grid when the browser is resized or a ContentPanel is collapsed and/or resized? I can't for the life of me get it to work.

I'm using the following to add the grid panel
layout.add('center', new Ext.GridPanel(myGrid.init(), {fitToFrame:true}));
and have a small class for my grid using Json data that returns the grid object after it's done setting up. I haven't been brave enough to try extending the grid class as in the props example yet. Is this maybe my problem?
var myGrid = {
    init : function(){

	    // define the "Topic" record, mapping json data to record fields
	    var Topic = Ext.data.Record.create([
	        {name: 'id', mapping: 'Id'},
	        {name: 'name', mapping: 'Name'},
	        {name: 'description', mapping: 'Description'},
	    ]);
	
	    // create reader that reads into Topic records
	    var reader = new Ext.data.JsonReader({
	        root: 'ResultSet',
	        totalProperty: 'totalCount',
	        id: 'id'
	    }, Topic);
	
	    // create the Data Store
	    var ds = new Ext.data.Store({
	        // load using script tags for cross domain
	        proxy: new Ext.data.HttpProxy({
	            url: 'http://fit/front_dev.php/workoutRoutine/getInfo'
	        }),
	
	        // let it know about the reader
	        reader: reader,
	        // turn on remote sorting
	        remoteSort: false
	    });
	    ds.setDefaultSort('name', 'desc');
	
	
	    // the column model has information about grid columns
	    // dataIndex maps the column to the specific data field in
	    // the data store
	    var cm = new Ext.grid.ColumnModel([{
	           id: 'ResultSet', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
	           header: "Id",
	           dataIndex: 'id',
	           //renderer: renderTopic,
	           css: 'white-space:normal;'
	        },{
	           header: "Name",
	           dataIndex: 'name',
	           //hidden: true
	        },{
	           header: "Description",
	           dataIndex: 'description',
	           //align: 'right'
	        }]);
	
	    // by default columns are sortable
	    cm.defaultSortable = true;
	
	    // create the editor grid
	    var grid = new Ext.grid.Grid('topic-grid', {
	        ds: ds,
	        cm: cm,
			autoSizeColumns: true,
			monitorWindowResize: true,
	        selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
	        enableColLock:false
	    });
	

	
	    // render it
	    grid.render();
	
	    var gridFoot = grid.getView().getFooterPanel(true);

	    // trigger the data store load
	    //ds.load({params:{start:0, limit:25, forumId: 4}});
		ds.load();
		return grid;
	}
};
While I'm sure my grid class isn't the best way to do it I'm still trying to learn.

Now my grid appears fine, autoscales to fit the current window size but if you resize the browser window smaller I get scroll bars and the columns don't resize. In .33 they resized if the browser or other content panels resized. Am I doing something wrong?
Reply With Quote
  #2  
Old 02-28-2007, 01:49 PM
Default

I don't know if you've figured this out yet but if you look at the code for GridPanel (in ContentPanels.js) it sets the onWindowResize flag to false (which overrides yours).

BTW - don't be afraid to dig into the source -- thanks to Jack its actually readeable
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值