1.在列屬性中加入事件
{
title:'數據量序號',
field:'sjid'
// hidden:true
},{
field: 'operate',
title: '操作',
width: '80px',
events: operateEvents,
formatter: operateFormatter
}
2.寫一個函數
function operateFormatter(value, row, index) {
return [
'<input type="submit" value="上傳" class="RoleOfedit btn btn-primary btn-sm" data-toggle="modal" >',
].join('');
}
3.記得這個寫在表格的前面
window.operateEvents = {
'click .RoleOfedit': function (e, value, row, index) {
alert(row.qxxh);
$("#upload").modal('show');
}
};
4.點擊“彈出模態框”
<div class="modal fade" id="upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form action="http://localhost:8080/GD/UploadAction_execute.action" method="post" enctype="multipart/form-data" name="uploadfile">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 class="modal-title" id="myModalLabelfile">上傳文件</h5>
</div>
<div class="modal-body">
<input type="file" name="my" id="file" value="瀏覽"
onchange="document.uploadfile.filePath.value=this.value"/>
<input type="text" name="filePath" id="filePath"/>
<input type="button" value="瀏覽..." onclick="document.uploadfile.my.click()"/><br>
<input type="submit" value="上傳" id="shangchuan">
</div>
<div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">關閉</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</form>
</div>
總結
以上所述是小編給大家介紹的BootStrap給table表格的每一行添加一個按鈕事件,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對億速云網站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。