Search code examples
extjsextjs2

Adding a non data bound row to a grid


This is a bit of a blast from the past, but anyway...

I have a grid, that loads from a store, with a rowselection model, and some buttons etc...

MyGrid = function(config){
    var config = Ext.apply({},config,{
    cm:'rowselection',
    store:new Ext.data.Store({
        ajax:true,
        url:'someUrl'
    })//thumbsucked config, this is prolly totally wrong
    });

    MyGrid.superclass.constructor.call(this, config);
}
Ext.extend(MyGrid,Extx.grid.GridPanel)

Now My question is...

How do I add a row to this grid without actually adding it to the store?

I want to do this so i can violate the column model ( eg I wanna add another row that has some textual info in it, and a hyperlink, which isn't gonna fit in my 4 column wide grid )

Can I access it as a dataview or something?

this.store.on('load',function(store,records,e){
        doWhat()
        //debugger;
    },this);
};

Solution

  • Guess you can over write the view, inside the Dom.

    this.store.on('load',function(store,records,e){
            rowTpl = new Ext.Template(
                '<div class="x-grid3-row x-grid3-row-last">',
                    '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
                        '<tbody><tr>{cellTpl}</tr></tbody>',
                    '</table>',
                '</div>'
            );
    
            cellTpl = new Ext.Template(
                '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}">',
                '<div class="x-grid3-cell-inner x-grid3-col-{id}"> Hello World</div>',
                "</td>"
            );
            cellTpl.compile();
    
            html=rowTpl.apply({
                tstyle: 'width:' + this.view.getTotalWidth() + ';',
                cellTpl: cellTpl.compile().html
            });
            Ext.DomHelper.insertHtml('beforeEnd', this.view.mainBody.dom, html);
        },this)