Ext JS – Putting an icon in a grid cell

One way to put an icon in a grid cell

1. Create CSS for the icon

td.locked {
	background: url(./images/icons/lock.png) no-repeat center !important;
}

2. Create a renderer that sets the css on the cell

var lockedRenderer = function(value, meta, record, rowindx, colindx, store) {
	if (value === true) {
		meta.css = 'locked'
	}
	return '';
};

3. Use column renderer in the column model. Code is just showing the column config for the one column.

{header: 'Locked', sortable: true, dataIndex: 'locked', renderer: lockedRenderer},

3 comments

Leave a reply to iNes Cancel reply