2015-12-01 14 views
1

嗨我試圖更改單元格文本到圖像當我itemmouseenter(鼠標懸停)網格行。ExtJS itemmouseenter(鼠標懸停)網格行並將單元格文本更改爲圖像

我有一個事件監聽器是這樣的:

itemmouseenter: function(me, record, item, index, e, eOpts) { 
    var store = this.getStore(); 
    var rowIndex = index; 
    store.getAt(rowIndex).set('name', '<img src="http://sstatic.net/stackoverflow/img/icon-16.png" />'); 
} 

事實上,它改變了文字到圖像,但它不能變回原來的文本。

我的目標就像css懸停效果。有任何建議可以做到這一點嗎?

感謝

Fiddle Sample

回答

2

如果使用record.set,你就會使電網刷新,這將影響性能。爲此,我寧願使用不會刷新的CSS。

看看這個小提琴:https://fiddle.sencha.com/#fiddle/11st

兩件事情來看待:

  1. 沒有聽衆對電網
  2. 檢查出的styles.css文件,查看使用:hover和改變display風格

使用CSS代替JavaScript像Gilsha的答案應該會導致更好的性能ANCE。

+0

太棒了!這種方式好多了 –

0

嘗試這種方式。更新fiddle

listeners: { 
    itemmouseenter: function(me, record, item, index, e, eOpts) { 
     record.set('_name', record.get('name')); 
     record.set('name', '<img src="http://sstatic.net/stackoverflow/img/icon-16.png" />'); 
    }, 
    itemmouseleave: function(me, record, item, index, e, eOpts) { 
     record.set('name', record.get('_name')); 
    } 
} 
+1

謝謝吉爾薩。它運作良好。我還在我的小提琴上添加了'markDirty:false'。該配置將清除單元格中的小紅色三角形。 –

+1

代替JavaScript並使用'record.set',使用CSS來獲得更好的性能。 –

+0

是的。你是對的:)謝謝指出.. – Gilsha

相關問題