show-cloud是後臺,going-client是對應的前臺項目。
going-client採用vue2的單也應用,具體技術細節不做介紹咯。這裏記錄下如何實現點擊一個單元格觸發相應的事件。
需求:點擊下發單位名稱,彈出下發單位明細列表
1、domain實體中定義相應字段
{ id: "canUseUnitNames", label: "下發單位名稱", width: 130,type:'custom',cellFun: "clickCanUseUnitCell",
loadCellFun(value:any, rowId:any, myGrid:any) {
return '<div style="color: #4A90E2;cursor: pointer" class="customerCell">' +
value +
"</div>"
},
config: {
saveGroup:false,
//標題
title: "選擇單位信息",
//顯示的tab頁
tabs: [{ id: "unit", active: true, accountSel: false }]
}, },
- 關鍵是定義loadCellFun:該函數改變值的顯示內容
- type爲custom:渲染類型
- 定義cellFun,cellFun爲vue裏面的method裏面的一個方法名稱
2、grid標籤註冊cellClick事件:
<!--表格-->
<go-single-grid
:hasPagin="true"
:hasToolBar="true"
:queryUrl="queryUrl"
:topHeight="10"
ref="gridObj"
id="roleGrid"
:config="roleConfig"
@cellClick="cellClick"
@afterLoadData="afterLoadData"
@switchEvent="switchEvent"
></go-single-grid>
3、定義clickCanUseUnitCell方法:
clickCanUseUnitCell({val,rowId}){
alert(rowId)
},