Ext js event fired or called after renderer

久未见 提交于 2019-12-13 06:19:14

问题


I have a grid column which uses the renderer function. Are the any events fired or called after this? I have tried several ones but they all get called on the whole column and they all fire before the renderer (even event afterrender)

thanks in advance


回答1:


afterrender only fires once when the column is laid out on the page. It is a basic ExtJS component event that almost all ExtJS components have and doesn't relate to the renderer function used for grid columns.

Not totally sure what you're trying to do this for... but if I wanted to trigger an event whenever my renderer function was executed I would fire a custom event from the renderer function itself. Something like this:

Ext.create('Ext.grid.Panel', {
    title: 'After Renderer Event Demo',
    store: Ext.getStore('DummyData'),
    columns: [{
        text: 'Column 1',  
        dataIndex:'aNumber',

        // dummy renderer function that fires an event after execution
        renderer: function(value) {

            // wrapping in a deferred function so that it fires AFTER
            Ext.defer(function() {
                this.fireEventArgs('aftercolumnrenderer', arguments);
            }, 10);

            if (value === 1) {
                return '1 person';
            }
            return value + ' people';
        }


    }, {
        text: 'Column 2',  
        dataIndex:'aString'
    }],
    width: 400,
    forceFit: true,
    renderTo: Ext.getBody()
});

I could listen for it directly with:

myColumn.on('aftercolumnrenderer', function(value, metaData, record, rowIndex, colIndex, store, view) {

    // do stuff

});

Or from within a controller's control function if you're using ExtJS MVC.

Also see fireEventArgs and the on method for reference.



来源:https://stackoverflow.com/questions/22539177/ext-js-event-fired-or-called-after-renderer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!