fastadmin 行内无刷新编辑editable插件使用方法详解

fastadmin 行内无刷新编辑editable插件使用方法详解_第1张图片

 

后台插件安装好后,只用设置js即可

define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'wd/guanli/index' + location.search,
                    add_url: 'wd/guanli/add',
                    edit_url: 'wd/guanli/edit',
                    del_url: 'wd/guanli/del',
                    multi_url: 'wd/guanli/multi',
                    import_url: 'wd/guanli/import',
                    table: 'wd_guanli',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'ID',
                sortName: 'ID',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'ID', title: __('Id')},
                        {field: 'IMEI', title: __('Imei')},
                        {field: 'hrz', title: __('Hrz'), operate: 'LIKE',editable: true,formatter:function (value, row, index) {
                            return  !value?'无':value;}},
                        {field: 'addr', title: __('Addr'), operate: 'LIKE',editable: true,formatter:function (value, row, index) {
                            return  !value?'无':value;}},
                        {field: 'temperature', title: __('Temperature'), operate:'BETWEEN'},
                        {field: 'temperatureCorrect', title: __('Temperaturecorrect')},
                        {field: 'humidity', title: __('Humidity'), operate:'BETWEEN'},
                        {field: 'humidityCorrect', title: __('Humiditycorrect')},
                        {field: 'voltage', title: __('Voltage'), operate:'BETWEEN'},
                        {field: 'signal', title: __('Signal')},
                        {field: 'isnetwork', title: __('Isnetwork')},
                        {field: 'version', title: __('Version')},
                        {field: 'collectTime', title: __('Collecttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'deviceId', title: __('Deviceid'), operate: 'LIKE'},
                        {field: 'macAddr', title: __('Macaddr'), operate: 'LIKE'},
                        {field: 'productId', title: __('Productid')},
                        {field: 'iccid', title: __('Iccid'), operate: 'LIKE'},
                        {field: 'admin_id', title: __('Admin_id'),editable: {
                        	type:'select',
                        	pk:1,
                        	source:[
                        		{value:'1',text:'总管理'},
                        		{value:'2',text:'西藏公司'},
                        		{value:'3',text:'河津公司'},
                        	],
                        }},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});

你可能感兴趣的:(fastadmin)