layui的table做批量刪除實(shí)現(xiàn)代碼如下:
// 批量刪除功能 // 1.得到table選中行內(nèi)容 // 2.得到刪除需要的唯一值,一般是id; // 3.將所要?jiǎng)h除的項(xiàng)加入到數(shù)組中; // 4.判斷是否選中; // 5.發(fā)送ajax請求,并附帶參數(shù)id; var $=layui.$,active={ deLink:function () { var checkStatus=table.checkStatus('idTest'), data=checkStatus.data, deList=[]; data.forEach(function(n,i){ delList.push(n.id); }); if(delList!=''){ layer.comfirm('確定刪除所選項(xiàng)嗎?',function (index) { $.ajax({ url: '/cd/workPlatform/tool/remove.afca', type:'post', dataType:'json', data:"id="+delList, success:function (data,statusText) { if(data.code==='0'){ layer.msg('刪除成功'); table.reload('idTest',{}); }else{ layer.msg('刪除失敗'); } }, 'error':function () { layer.msg('系統(tǒng)錯(cuò)誤'); } }) }) }else{ layer.tips('請選擇需要?jiǎng)h除的行',$('#batchDel'),{ tips:[3,'#5fb878'] }) } } }
推薦:layui框架教程
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com