cwr-toki

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\');

 

分类:

技术点:

相关文章:

  • 2021-07-16
  • 2021-11-21
  • 2022-03-08
  • 2021-06-29
  • 2021-11-23
  • 2021-11-23
  • 2022-02-28
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2021-11-23
  • 2021-11-10
  • 2022-12-23
  • 2021-04-03
  • 2021-12-31
相关资源
相似解决方案