BootStrap給table表格的每一行添加一個按鈕事件
更新時間:2017年09月07日 11:47:36 作者:xingxuexue
這篇文章主要介紹了BootStrap給table表格的每一行添加一個按鈕事件的相關(guān)資料,需要的朋友可以參考下
1.在列屬性中加入事件
{
title:'數(shù)據(jù)量序號',
field:'sjid'
// hidden:true
},{
field: 'operate',
title: '操作',
width: '80px',
events: operateEvents,
formatter: operateFormatter
}
2.寫一個函數(shù)
function operateFormatter(value, row, index) {
return [
'<input type="submit" value="上傳" class="RoleOfedit btn btn-primary btn-sm" data-toggle="modal" style="display:inline">',
].join('');
}
3.記得這個寫在表格的前面
window.operateEvents = {
'click .RoleOfedit': function (e, value, row, index) {
alert(row.qxxh);
$("#upload").modal('show');
}
};
4.點擊“彈出模態(tài)框”
<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>
<h4 class="modal-title" id="myModalLabelfile">上傳文件</h4>
</div>
<div class="modal-body">
<input type="file" name="my" id="file" value="瀏覽" style="display: none;"
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">關(guān)閉</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</form>
</div>
總結(jié)
以上所述是小編給大家介紹的BootStrap給table表格的每一行添加一個按鈕事件,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
關(guān)于獲取DIV內(nèi)部內(nèi)容報錯的原因分析及解決辦法
這篇文章主要介紹了關(guān)于獲取DIV內(nèi)部內(nèi)容報錯的原因分析及解決辦法的相關(guān)資料,需要的朋友可以參考下2016-01-01
JS實現(xiàn)pasteHTML兼容ie,firefox,chrome的方法
這篇文章主要介紹了JS實現(xiàn)pasteHTML兼容ie,firefox,chrome的方法,涉及javascript針對頁面元素的動態(tài)操作技巧,具有一定參考借鑒價值,需要的朋友可以參考下2016-06-06
微信小程序?qū)崿F(xiàn)授權(quán)登錄之獲取用戶信息
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)授權(quán)登錄之獲取用戶信息,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-05-05
JavaScript 中的12種循環(huán)遍歷方法【總結(jié)】
本文給大家總結(jié)了12種JavaScript 中的1循環(huán)遍歷方法,每種方法通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2018-05-05
javascript強(qiáng)制彈出新窗口實現(xiàn)代碼
javascript強(qiáng)制彈出新窗口,主要是利用的動態(tài)創(chuàng)建鏈接。2009-12-12

