Home > Web Front-end > JS Tutorial > How to add a picture state or button to Extjs grid_extjs

How to add a picture state or button to Extjs grid_extjs

WBOY
Release: 2016-05-16 16:53:30
Original
1299 people have browsed it

We often need to add a picture status or button in the extjs grid. Let’s summarize the methods we have used:

1. Status representation:

Copy code The code is as follows:

renderer:function(value){
if(value==0){
return "";
}else if(value==1){
return "";
}
return value;
}

Add renderer identification status in columns. The effect is as follows:

http://images.cnitblog.com/ blog/489550/201304/19103818-94991d9869a6458e8a568efdea6081b5.png

2. Event handling:

Add onclick event directly to img:
Copy the code The code is as follows:

Detailed Maintenance'

The event is to pass the required data.

Another way is to add a cell click event to the grid:
Copy the code The code is as follows:

listeners: {
cellClick: viewDoc
}

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

}

In this way, you can get the clicked cell and then add event processing.

3. You can use 'actioncolumn' to add image buttons
Copy code The code is as follows:

{header:'certificate',sortable:false,width:80,align:'center',scope:this,

xtype:

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

This way you can also add pictures to grid cells.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template