問題描述
我的代碼如下,我想在layui表格中選擇下拉框同時拿到這一行對應的id值,要怎么寫才能獲取到呢?
,cols: [[ //表頭
{type: 'checkbox', fixed: 'left'}
,{field: 'id', title: 'id', width:140,hide:true}
,{field: 'loginid', title: '用戶名', width:'10%'}
,{field: 'name', title: '姓名', width:'10%'}
,{field: 'sex', title: '性別', width:'10%'}
,{field: 'phone', title: '電話', width:'10%'}
,{
field: 'taskNature',
title: '狀態',
width:170,
align:'center',
templet: function (d) {
return `<select name="ac" lay-verify="required" lay-filter="stateSelect">
<option value="0" ${d.taskNature == 0 ? "selected":""}>未完成</option>
<option value="1" ${d.taskNature == 1 ? "selected":""}>已完成</option>
</select>`;
}
}
,{field: 'record', title: '回訪記錄', width:'50%',edit:'text'}
]]
form.on('select(stateSelect)', function (data) {//獲取當前行tr對象
//拿到當前行的ID
//拿到當前行的值
})
推薦答案
form.on('select(stateSelect)', function (data) {//獲取當前行tr對象
//獲取當前行tr對象
var elem = data.othis.parents('tr');
//拿到當前行的ID
//第一列的值是ID,取ID來判斷
var ID= elem.first().find('td').eq(1).text();
//拿到當前行的值
})
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!