给Ext.Grid添加属性:afterRender
afterRender: Ext.Function.createSequence(Ext.grid.GridPanel.prototype.afterRender, tipShow)
//顯示文本 function tipShow() { //默認顯示文本 var view = this.getView(); this.tip = new Ext.ToolTip({ target: view.el, delegate: '.x-grid-cell-inner', trackMouse: true, renderTo: Ext.getBody(), listeners: { beforeshow: function updateTipBody(tip) { //要显示文本内容 var tipText = ""; if (tip && tip.triggerElement && tip.triggerElement.innerHTML) { //取cell的值,这里显示为grid单元格的内容 tipText = tip.triggerElement.innerHTML; } if (!tipText.trim().length || tipText == " ") { return false; } tip.update(tipText); } } }); }