columns: [{
checkbox: true
}, {
field: 'id',
title: 'id'
}, {
field: 'role_id',
title: 'role_id'
}, {
field: 'resource_id',
title: 'resource_id'
}, {
title: '操作',
field: 'id',
align: 'center',
events:window.operatEvents = {
'click .mod': function(e,value,row,index){
alert('A');
}
},
formatter:function(value,row,index){
return [
'<a class="mod" >修改</a>',
'<a class="btn btn-default" data-toggle="delete"> <i class="fa fa-trash"></i>洗掉</a>'
].join('');
},
cellStyle:{
css:{"width":"20%"}
},
}]
為什么我的events不執行
uj5u.com熱心網友回復:
window.operateEvents最好單獨寫出來,因為window.operateEvents要在表格前面進行注冊宣告uj5u.com熱心網友回復:
https://www.jb51.net/article/123134.htmuj5u.com熱心網友回復:
因為你的操作列的field的值跟上面的field: 'id',
title: 'id'
有重疊,所以才不會執行,你的操作列的field改成其他的,比如cc就行了
uj5u.com熱心網友回復:
樓上正解!!!uj5u.com熱心網友回復:
為什么我的event從未執行呢,之前是這么寫的,而且也寫了宣告window.operationEvent ={}event:operationEvent,
formatter: addDownLord
operationEvent報錯,說是未宣告
后來我這樣寫也不管用,這個點擊事件從來就沒有進來過
event: window.operationEvent = {
'click .btn_delete': function (e, value, row, index) { console.log(111) },
'click .btn_down': function (e, value, row, index) { console.log(222) }
},
formatter: addDownLord
}
uj5u.com熱心網友回復:
執行順序問題 參考一下代碼:window.operateEvents = {
'click .like': function (e, value, row, index) {
alert('You click like action, row: ' + JSON.stringify(row))
},
'click .remove': function (e, value, row, index) {
$table.bootstrapTable('remove', {
field: 'id',
values: [row.id]
})
}
}
//page與表格合體的PageList控制元件
var $table = new PageList("#table", {
sidePagination: "client", //client客戶端分頁
dataField: "obj",//資料欄位
columns: [
{checkbox: true,visible: true},
{title: '編號', field: 'bh'},
{title: '姓名', field: 'xm'},
{title: '軍人保障卡號', field: 'jrbzkh'},
{title: '性別', field: 'xb'},
{title: '職部別', field: 'bzb'},
{
field: 'id',
title: '操作',
align: 'center',
clickToSelect: false,
events: window.operateEvents,
formatter: operateFormatter
}
],
url: Conf.interfaces.PERSONNEL
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/235709.html
標籤:Web 開發
