Extjs create a grid feature or grid plugin that sets a tooltip for each column in the grid

后端 未结 2 751
星月不相逢
星月不相逢 2021-01-20 02:39

This question has the answer to adding the tooltip: Extjs4 set tooltip on each column hover in gridPanel

I have a follow up question to the most upvoted answer to t

2条回答
  •  梦毁少年i
    2021-01-20 03:21

    In your plugins init method, you will be able to loop through the columns of the grid (the constructor and initComponent methods of the grid will have already been called at this point).

    That means that you can inspect each column to see if the user has setup a custom renderer. If there is none, you can put your one, and if there is one, you can chain the existing renderer with yours.

    EDIT

    Ext.define('My.Plugin', {
    
        init: function(grid) {
    
            // You may not need the scope, but if you do, this binding will
            // allow to preserve the scope configured in the column...
            var pluginRenderer = Ext.Function.bind(this.renderer, this);
    
            Ext.each(grid.query('gridcolumn'), function(col) {
                var renderer = col.renderer;
                col.renderer = renderer
                    ? Ext.Function.createSequence(renderer, pluginRenderer)
                    : pluginRenderer;
            });
        }
    
        ,renderer: function(value, md) {
    
            // ...
    
            // You must return, in case your renderer is the only one (if
            // there is another one, this return will be ignored by createSequence)
            return value;
        }
    });
    

提交回复
热议问题