【Fastadmin】表格列改input框输入编辑,以排序权重为例

// 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                sortOrder: 'desc',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'major_code', title: __('Major_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'pid', title: __('Pid')},
                        // {field: 'level_id', title: __('Level_id')},
                        {field: 'level.level_name', title: __('Level.level_name'), operate: false, table: table, class: 'autocontent'},
                        {field: 'grade', title: __('Grade'), operate: false, searchList: {"1":__('Grade 1'),"2":__('Grade 2'),"3":__('Grade 3')}, formatter: Table.api.formatter.normal},
                        // {field: 'weigh', title: __('权重'), operate: false, },
                        //排序自定义输入框
                        {field: 'weigh', title: __('权重'),width: 80,operate: false,formatter: Controller.api.formatter.input,events: {".text-weigh": function (e) {
                                    e.preventDefault();
                                    e.stopPropagation();
                                    return false;
                        }}},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
            // 如果字段变化,改此处的weigh即可
            table.closest('.bootstrap-table').on("change", ".text-weigh", function () {

                $(this).data("params", {weigh: $(this).val()});
                Table.api.multi('', [$(this).data("id")], table, this);
                return false;
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

            table.off('dbl-click-row.bs.table');
api: {
    formatter: {
        input: function (value, row, index) {
            value = value == null || value.length === 0 ? '' : value.toString();
            return '<input type="text" class="form-control input-sm text-weigh" data-id="' + row.id + '" value="' + value + '">';
        },
    },
    bindevent: function () {
        Form.api.bindevent($("form[role=form]"));
    }
}
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值