Extjs grid添加圖片,按鈕和超連結

來源:互聯網
上載者:User

extjs的grid中我們經常需要添加一個圖片狀態或者按鈕,總結一下自己用過的方法:

一、狀態表示:

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

在columns中列添加renderer標識狀態,如下:

二、事件處理:

直接給img添加onclick事件:

<img style="cursor:pointer;" onclick="updateRecord(\''+sn+"@"+ss+"@"+record.get("standardId")+'\');" src=\'${ctx}/img/edit.png\' alt=\'明細維護\' title=\'明細維護\'>'

事件是將需要的資料傳遞過去。

還有一種方法就是給grid添加儲存格點擊事件:

listeners: {    cellClick: viewDoc}
function viewDoc(grid, rowIdx, colIdx, e) {    var action = e.getTarget().value;
}
這樣就可以得到點擊的儲存格,再添加事件處理即可。

三、可以使用'actioncolumn'添加圖片按鈕

{header:'合格證',sortable:false,width:80,align:'center',scope:this,

xtype:

'actioncolumn',    items : [{              icon : '${ctx}/img/details.png',              tooltip : '顯示合格證',              handler : function(grid, rowIndex, colIndex) {                   var record = grid.getStore().getAt(rowIndex);                    //。。。          }]} 
這樣也可以在grid儲存格中添加圖片。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.