开发者

extjs 4 rendering tooltip on grid on tabpanel

开发者 https://www.devze.com 2023-03-31 18:20 出处:网络
i am working with Extjs 4 & using Designer 1.2.0 i am facing problems with grid\'s renderer function that i am using to display tooltip. The grid is placed in tab panel. Everything works fine for

i am working with Extjs 4 & using Designer 1.2.0 i am facing problems with grid's renderer function that i am using to display tooltip. The grid is placed in tab panel. Everything works fine for first time when i open tab panel,but when i close tab panel & reopen it , the initComponent() does not get called again & so tooltip does not show up & hyperlink effect goes开发者_如何学JAVA off. What can be solution for this problem? below is my code :

Ext.define('MyApp.view.ItemManager', {
    extend: 'MyApp.view.ui.ItemManager',

    initComponent: function() {
       Ext.QuickTips.init();
         var me = this;
         me.callParent(arguments);
              me.down('#itemManager').columns[3].renderer=function(value,metaData,record,colIndex,store,view){
                var imgpath="<img style=\'margin: 2px 0;height:150px;width:150px;\' src=\' /items/"+record.data.id +" '/>";

                metaData.tdAttr = 'data-qtip=" '+imgpath +'"' ;
                return '<a href="/items/imgdownload?id='+record.data.id+'">'+ record.data.img_filename +'</a>';
              }
      }
});

However when i write renderer code in ui file generated by exporting project from designer then everything works fine. The problem is if i write renderer in ui file, it will get overwritten everytime i export the project :(


  1. Ext.QuickTips.init() should only be called 1 time and needs to be relocated to a global location.
  2. You need to relocate your rendered definition to the actual column it belongs to: { ..., dataIndex : 'myColumn', rendered : function (value, metaData, etc) { return value; }, title : 'My Column Title', ... }

EDIT

Below is an example:

Ext.define('MyApp.view.ItemManager', {
    extend: 'MyApp.view.ui.ItemManager',

    initComponent: function() {
        //Ext.QuickTips.init(); // move to global js file. only call once.
        var me = this;
        me.callParent(arguments);

        if (!me.down('#itemManager').columns[3].renderer) {
            me.down('#itemManager').columns[3].renderer=function(value,metaData,record,colIndex,store,view) {
                var imgpath="<img style=\'margin: 2px 0;height:150px;width:150px;\' src=\' /items/"+record.data.id +" '/>";

                metaData.tdAttr = 'data-qtip=" '+imgpath +'"' ;
                return '<a href="/items/imgdownload?id='+record.data.id+'">'+ record.data.img_filename +'</a>';
            }
        }
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消