2011-09-24 4 views
3

現在の列の各行によってマウスのホバー上にツールチップが表示されていますが、同じ行のホバーを続けると次の列のツールチップを取得できません。Extjs4は、gridPanel内の各列のホバー上にツールチップを設定しました

しかし、私は別の行&に置く場合、私は再び使用して、前の行の任意の列を置くそれを得ることができます。

listeners:{ 
'itemmouseenter': function (view, record, item, index, e, eOpts) { 
     var gridColums = view.getGridColumns(); 
     var column = gridColums[e.getTarget(this.view.cellSelector).cellIndex]; 
     Ext.fly(item).set({ 'data-qtip': 'Des:' + column.dataIndex }); 

    } 
} 

誰もが私が欠けているものを私に表示したり、正しい方向に私を指すことができます?

答えて

5

私はこれを見ていました。私はこのような何かを行うことによって、各セルのツールヒントを得るために管理することができます:

Ext.getCmp('DynamicDemandGrid').getView().on('render', function(view) { 
    view.tip = Ext.create('Ext.tip.ToolTip', { 
     // The overall target element. 
     target: view.el, 
     // Each grid row causes its own seperate show and hide. 
     delegate: view.cellSelector, 
     // Moving within the row should not hide the tip. 
     trackMouse: true, 
     // Render immediately so that tip.body can be referenced prior to the first show. 
     renderTo: Ext.getBody(), 
     listeners: { 
      // Change content dynamically depending on which element triggered the show. 
      beforeshow: function updateTipBody(tip) { 
       var gridColums = view.getGridColumns(); 
       var column = gridColums[tip.triggerElement.cellIndex]; 
       var val=view.getRecord(tip.triggerElement.parentNode).get(column.dataIndex); 
       tip.update(val); 
      } 
     } 
    }); 
}); 

私はそれが

28

を助け場合、私はレンダラー機能を使用して、簡単なものを持って知ってみましょう:

{ 
    xtype : 'gridcolumn', 
    dataIndex : 'status', 
    text : 'Status', 
    renderer : function(value, metadata) { 
        metadata.tdAttr = 'data-qtip="' + value + '"'; 
        return value; 
       } 
} 
+0

これは素早い解決策です。ありがとう! – sunny

+0

私はこれに後続の質問があります。上記の実装を使用してカスタムツールチップを設定するグリッドプラグインまたは機能が必要です。質問は、どのように私のものをレンダラー関数に追加することができますが、同時に、特定のグリッドに使用されているユーザー定義のレンダラー関数を取り除くことはありません。基本的には、すべてのグリッドにツールチップ機能を追加したいが、一部のグリッドの一部の列に対してカスタムレンダラーを指定する機能は取り除かない。 – dreamerkumar

+1

rixoが私のためにこれを答えました:http://stackoverflow.com/questions/18536202/extjs-create-a-grid-feature-or-grid-plugin-that-sets-a-tooltip-for-each-column -i/18536873?noredirect = 1#comment27264689_18536873 – dreamerkumar

2
{ 
    text: name, 
    width: 80, 
    dataIndex: dataIndex, 
    sortable: true, 
    listeners: { 
     afterrender: function() 
     { 
      Ext.create('Ext.ToolTip', 
      { 
       target: this.getEl(), 
       anchor: direction | "top", 
       trackMouse: true, 
       html: this.text 
      }); 
     } 
    } 
} 
関連する問題