0
votes

I'm displaying images in an ExtJS grid by using column renderers that return HTML tags. The issue is that the images "flicker" (i.e., vanish and re-appear) each time the grid is updated. Is there a way to prevent this? Here's a simplified example of what I'm doing:

Ext.create('Ext.grid.Panel', {
  title: 'My Grid',
  store: myStore
  columns: [
    {
      header: 'Image', 
      dataIndex: 'imgUrl',
      renderer: function(imgUrl, meta, record) {

        // Add a mouse-over / tooltip that shows the name
        meta.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(record.getName()) + '"';

        return '<img src="' + imgUrl + '">';
      }
    }
  ]
});
1
Do your images get cached by the browser?Dmitry Pashkevich
Great question. I did confirm that they are being cached. Each time the grid updates the browser isn't re-requesting them.Clint Harris

1 Answers

0
votes

I found that using a CSS background-image instead of an <img> tag fixes the problem (only tested with Chrome). Example:

Ext.create('Ext.grid.Panel', {
  title: 'My Grid',
  store: myStore
  columns: [
    {
      header: 'Image', 
      dataIndex: 'imgUrl',

      width: 16, // The width of the background-image

      renderer: function(imgUrl, meta, record) {

        // Add a mouse-over / tooltip that shows the name
        meta.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(record.getName()) + '"';

        meta.tdAttr += 'style="background-image: url(\'' + imgUrl + '\'); background-repeat: no-repeat;"';
      }
    }
  ]
});