bootstrap table可编辑

在table init中加入此段代码

onDblClickCell: function(field,value,row,$element) {
                        var upIndex = $element[0].parentElement.rowIndex - 1;
                        var params = options.editFiled.split(",");
                        for (item in params) {
                            if (params[item] == field) {
                                $element[0].innerHTML = "<input id='inputCell' type='text' name='inputCell' style ='width: 40px' value='" + value + "'>";
                                $("#inputCell").focus();
                                $("#inputCell").blur(function () {
                                    var newValue = $("#inputCell").val();
                                    row[field] = newValue;
                                    $(this).remove();
                                    $('#bootstrap-table').bootstrapTable('updateCell', {
                                        index: upIndex,
                                        field: field,
                                        value: newValue
                                    });
                                });
                            }
                        }
                    }

在options中加入

editFiled: "model,num,unitPrice,totalAmount,outStockId,remark,wareTime",//多个用逗号隔开

可编辑select,需加入bootstrap-editable.css,bootstrap-table-editable.js

editable: {
                            type: 'select',
                            title: '类型',
                            name: 'type',
                            emptytext: "请选择类型",
                            placement: 'top',
                            source : function() {//动态获取数据
                                var result = [];
                                result.push({
                                    value : 1,
                                    text : '配件入库'
                                });
                                return result;
                            },
                            select: {
                                allowClear: true,
                                multiple: false,
                                tokenSeparators: [",", " "],
                                width: '150px'//设置宽
                            }
                        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值