Method to add a picture state or button to the Extjs grid

  • 2020-03-30 02:30:42
  • OfStack

In the extjs grid, we often need to add a picture state or button. Summarize the methods we have used:

I. status expression:
return "<img src='images/icons/cancel.png'>"; 
}else if(value==1){ 
return "<img src='images/icons/accept.png'>"; 
return value; 

Add the status of renderer in columns. The effect diagram is as follows:

Ii. Event handling:

Add the onclick event to img directly:
<img style="cursor:pointer;" onclick="updateRecord(''+sn+"@"+ss+"@"+record.get("standardId")+'');" src='${ctx}/img/edit.png' alt=' Details of maintenance ' title=' Details of maintenance '>' 

An event is the passing of the required data.

Another way is to add a cell click event to the grid:
listeners: { 
cellClick: viewDoc 

function viewDoc(grid, rowIdx, colIdx, e) { 
var action = e.getTarget().value; 


This will give you the cells to click on, and then add the event handling.

You can use 'actioncolumn' to add a picture button
{header:' Certificate of approval ',sortable:false,width:80,align:'center',scope:this, 


items : [{ 
icon : '${ctx}/img/details.png', 
tooltip : ' Display certificate ', 
handler : function(grid, rowIndex, colIndex) { 
var record = grid.getStore().getAt(rowIndex); 
// .  

This also allows you to add pictures to the grid cell.

Related articles: