ExtJS 3.4在网格底部添加按钮

时间:2012-03-28 09:59:30

标签: button grid extjs3 gridpanel

我是ExtJS的新手,并尝试在网格底部添加一个按钮。此按钮将打开一个模式对话框以选择更多人。我不知道如何在网格后添加此按钮。我是否必须使用除GridPanel之外的其他组件?

有人能帮助我吗?

代码如下:

var selectedPersons = [
    [1, 'Persnr', 'Name', 'Vorname']
];

var store = new Ext.data.ArrayStore({
    fields: [
        {name: 'PrsOid', type: 'int'},
        {name: 'PersonalNr'},
        {name: 'Nachname'},
        {name: 'Vorname'}
    ]
});

store.loadData(selectedPersons);

var grid = new Ext.grid.GridPanel({
    store: store,
    columns: 
    [
        {
            id       : 'PersonalNr',
            header   : 'PersonalNr', 
            width    : 100,
            sortable : true, 
            dataIndex: 'PersonalNr'
        },
        {
            header   : 'Nachname', 
            width    : 100,
            sortable : true, 
            dataIndex: 'Nachname'
        },
        {
            header   : 'Vorname', 
            width    : 100,
            sortable : true, 
            dataIndex: 'Vorname'
        }
    ],
    stripeRows: true,
    autoExpandColumn: 'PersonalNr',
    height: 200,
    //width: 460,
    title: 'Personenauswahl',
    // config options for stateful behavior
    stateful: true,
    stateId: 'grid'
    });

    grid.render('gridSelectedPersons');

1 个答案:

答案 0 :(得分:3)

你的意思是像底栏吗?

var grid = new Ext.grid.GridPanel({
    store: store,
    columns: 
    [
       ....
    ],
    stripeRows: true,
    autoExpandColumn: 'PersonalNr',
    bbar: new Ext.Toolbar({
         renderTo: document.body,
         height: 30,
         items: [
           // begin using the right-justified button container
           '->',
           {
             xtype:'button',
             text:'The button',
             //makes the button 24px high, there is also 'large' for this config
             scale: 'medium'
           }
         ]
        })