bootstrapTable中添加按钮

  • A+
所属分类:JQuery/Js 技术杂谈

  columns: [
                        {
                            field: 'kcmc',
                            title: '课程名称'
                        },
                        {
                            field: 'kc_uuid',
                            title: 'ID',
                            width: 360
                        },
                        
                        {
                            field: 'pxzq',
                            title: '培训周期'
                        },
                        {
                            field: 'pxfy',
                            title: '培训费用'
                        },
                        {
                            field: 'beizhu',
                            title: '备注'
                        },
                        {
                            field: 'tjsj',
                            title: '录入时间'
                        },
                        {
                            field: '',
                            title: "操作",
                            formatter:operateFormatter    
                        }

在需要添加按钮的字段中添加 formatter 属性,例如我在案例中添加的操作一栏,并添加 operateFormatter 函数

   function operateFormatter(value, row, index) {
        //只有顶级可以进行按钮操作
        //不做判断,所有列都会有按钮
           if (!row.pid){
               return ['<button  type="button" class="btn btn-primary btn-xs">添加批次</button>', ].join('');
           }else{
               return ['<button  type="button" disabled class="btn btn-primary btn-xs">添加批次</button>', ].join('');
           }
    }

结果如图:

bootstrapTable中添加按钮

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: