Extjs - How to show combobox in Grid column

前端 未结 5 1425
难免孤独
难免孤独 2021-02-07 06:27

I have a gridpanel include date and combo column jsfiddle

But I don\'t want click to show my combo. I want show my combo without click, not hide inside

5条回答
  •  遥遥无期
    2021-02-07 07:00

    Ok, here is a complete example of how to use Combo Boxes in Sencha EXTJS:

    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        columns: [{
            xtype: 'gridcolumn',
            text: 'UserStatus',
            dataIndex: 'userstatus',
            editor: {
                xtype: 'combobox',
                allowBlank: false,
                displayField: 'Name',
                valueField: 'Id',
                queryMode: 'local',
                store: this.getStatusChoicesStore()
            }
        }],
        width: 450,
        renderTo: Ext.getElementById('hede')
    });
    

    Now the this.getStatusChoicesStore() function will provide us with the choices for this combo box (you can define that function anywhere, or just inline it inside the columns definition, for me it keeps easier to read if I create a function for it):

    getStatusChoicesStore: function() {
        return Ext.create('Ext.data.Store', {
            data: [{
                Id: 0,
                Name: "Active"
            }, {
                Id: 1,
                Name: "Inactive"
            }]
        });
    },
    

    Additionally, more info and examples can be found here.

提交回复
热议问题