• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
toki!
博客园    首页    新随笔    联系   管理    订阅  订阅
bootstrap-editable实现bootstrap-table行内编辑

bootstrap-editable行内编辑效果如下:

需要引入插件

列初始化代码,为可编辑的列添加editable属性:

columns = [
             {
                 title: '文件名',
                 field: 'Name',
                 align: 'center',
                 valign: 'middle',
                 sortable: true,
                 width: '20%'
             }, {
                 title: '文件版本号',
                 field: 'VerNum',
                 align: 'center',
                 valign: 'middle',
                 sortable: true,
                 width: '20%',
                 editable:{
                     emptytext: '-',
                 }
             }, {
                 title: '文件描述',
                 field: 'Description',
                 align: 'center',
                 valign: 'middle',
                 editable: {
                     emptytext: '-'
                 }
             }, {
                 title: '文件ID',
                 field: 'ObjectId',
                 visible: false
             }
    ]

保存修改后台调用方法:

function $onRowEditableSave(field, row, oldValue, $el) {        
        $.ajax({
            type: "post",
            url: "../FilesDownload/Edit?type=FileInfo",
            data: { strJson: JSON.stringify(row) },
            success: function (data, status) {
                if (data == "1" && status == "success") {
                    showTip('修改成功!', "success");                    
                    refreshTable();
                    $('#table .editable').editable('enable');
                    $('#btn_offeditfile').hide();
                    $('#btn_editfile').show();
                }
                else {
                    showTip('修改失败!', "error");
                    refreshTable();
                    $('#table .editable').editable('enable');
                    $('#btn_offeditfile').hide();
                    $('#btn_editfile').show();
                }
            },
            error: function () {

                showTip('连接服务器超时!', "error");
            },
            complete: function () {

            }

        });
    }

通过js动态控制是否可编辑:

$('#table .editable').editable('disable');

 

posted on 2018-10-26 10:00  toki!  阅读(3147)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3