Search code examples
extjsextjs6.2

How to add an additional button to a column header (extjs 6.2)


i need to add a button to the column header besides the filters menu (like the blue mark on the photo)

button where's the blue mark


Solution

  • A little hack like this could work. Just get the layout aligned to show content in left and right most parts of Container.

    Ext.create('Ext.container.Viewport', {
    layout: 'fit',
    
    items: [{
        xtype: 'container',
        items: [{
            xtype: 'grid',
            sortable: true,
            columns: [{
                flex: 1
            }, {
                text: "Age",
                flex: 1
            }],
            listeners: {
                afterrender: function (grid) {
                    var columns = grid.columnManager.getColumns();
                    var nameCol = columns[0];
                    var targetDom = nameCol.textInnerEl.dom;
                    var newPanel = Ext.create('Ext.container.Container', {
                        items: [{
                            xtype: 'label',
                            text: "Name"
                        }, {
                            xtype: 'button',
                            text: "DO IT"
                        }],
                        renderTo: targetDom
                       });
                   }
               }
            }]
       }]
    });
    

    Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/29o8