123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'example/controllerjump/index',
- add_url: '',
- edit_url: '',
- del_url: 'example/controllerjump/del',
- multi_url: '',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- columns: [
- [
- {field: 'state', checkbox: true, },
- {field: 'id', title: 'ID'},
- {field: 'admin_id', title: __('Admin_id')},
- {field: 'title', title: __('Title')},
- {field: 'ip', title: __('IP'),formatter: Controller.api.formatter.ip},
- {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- edit: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- api: {
- formatter: {
- ip: function (value, row, index) {
- //这里手动构造URL
- url = "example/bootstraptable?" + this.field + "=" + value;
- //方式一,直接返回class带有addtabsit的链接,这可以方便自定义显示内容
- //return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __('Search %s', value) + '</a>';
- //方式二,直接调用Table.api.formatter.addtabs
- this.url = url;
- return Table.api.formatter.addtabs.call(this, value, row, index);
- }
- }
- }
- };
- return Controller;
- });
|