如何设置gridPanel的行高度 extjs-CSDN论坛

2025-04-11 09:49:24
推荐回答(1个)
回答(1):

两种方式:

一、通过配置项height,在新建grid的时候就指定高度;

二、通过grid中的setHeight()方法动态指定高度。

Ext.create('Ext.data.Store', {
    storeId:'simpsonsStore',
    fields:['name', 'email', 'phone'],
    data:{'items':[
        { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },
        { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" }
    ]},
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});

var grid = Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    store: Ext.data.StoreManager.lookup('simpsonsStore'),
    columns: [
        { text: 'Name',  dataIndex: 'name' },
        { text: 'Email', dataIndex: 'email', flex: 1 },
        { text: 'Phone', dataIndex: 'phone' }
    ],
    height: 150,  //这里是配置项方式设置高度(方式一)

    width: 400,
    renderTo: Ext.getBody()
});

//这里是方法设置(方式二)

grid.setHeight(200);

 

//希望对你有所帮助,建议多看看官方API,我的例子就是那里复制过来的。