移动idEvents脚本到框架中

This commit is contained in:
Argo-Lenovo 2016-10-24 19:12:22 +08:00
parent f2e49df6a3
commit ede9868d1b
2 changed files with 16 additions and 11 deletions

View File

@ -48,6 +48,20 @@
BootstrapAdmin.prototype = {
constructor: BootstrapAdmin,
idEvents: function () {
var op = {
dataEntity: this.options.dataEntity,
table: this.options.bootstrapTable,
modal: this.options.modal
};
return {
'click .edit': function (e, value, row, index) {
op.dataEntity.load(row);
$('#' + op.table).bootstrapTable('uncheckAll').bootstrapTable('check', index);
$('#' + op.modal).modal("show");
}
}
},
query: function () {
if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh');

View File

@ -8,7 +8,7 @@
}
});
var extender = new BootstrapAdmin({
var bsa = new BootstrapAdmin({
url: '../api/Users',
dataEntity: dataEntity,
click: {
@ -20,21 +20,12 @@
}
});
idEvents = {
'click .edit': function (e, value, row, index) {
dataEntity.load(row);
$('table').bootstrapTable('uncheckAll');
$('table').bootstrapTable('check', index);
$("#dialogNew").modal("show");
}
};
$('table').smartTable({
url: '../api/Users', //请求后台的URL*
sortName: 'UserName',
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val() }); }, //传递参数(*
columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: idEvents, formatter: BootstrapAdmin.idFormatter },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "用户名称", field: "UserName", sortable: true }
]
});