1 store中解析列的时候添加超链接处理
{header : '操作',dataIndex : 'type',sortable : true,width : 300,renderer:function(value, metaData, record, rowIndex, colIndex, store){ if( record.get('courseStatue')=="结束"){ return ""; }else{ return " <a href='#' style='color:blue' name='stuInfoMng'>学员管理</a>" + " |<a href='#' style='color:blue' name='checkingIn'>考勤</a> " ; } }}
2 grid单元格中添加单击事件
listeners:{ cellclick:function(grid,rowIndex,columnIndex,e){ var rstore = grid.getStore(), record = rstore.getAt(rowIndex); if(columnIndex==8){ //点击的列 if(!e.getTarget("a"))return; //点击的是超链接 var target = e.getTarget("a").name; //取超链接的名字,根据名字不同添加不同的函数 if(target=="stuInfoMng"){ //学员管理 getClassStuInfo(record.get("id")); }else (target=="checkingIn"){ //考勤管理 getCheckingIn(record.get("id")); } } } }
3 添加需要执行的方法
// 查询班级的学生 function getClassStuInfo(id ){ alert("添加了单击事件"); }