0

问题描述

在对bootstrap-editable 进行编辑时,有两种使用方法:
一种直接在每一个column中进行编辑保存,例如
{

                            title:'标题',
                            field:'title',
                            width:160,
                            align:'left',
                            valign:'middle',
                            sortable:false,
                            searchable:false,
                            editable: {
                                type: 'text',
                                title: '标题',
                                mode: "popup",
                                emptytext: "--",
                                validate: function (v) {
                                    if (!v) return '标题不能为空';
                                },
                                url:'/edit_todo',
                                success: function(response, newValue) {
                                    if(response=='nouser'){
                                        return "请先登录!";
                                    }
                                    if(response=='7'){
                                        return "对不起,您无此操作权限!";
                                    }
                                    if(response.status =='error') {
                                        return response.msg;
                                    }
                                }
                            }

                        },{
                            title:'描述',
                            field:'description',
                            align:'left',
                            valign:'middle',
                            sortable:false,
                            searchable:false,
                            width:400,
                            editable: {
                                type: 'textarea',
                                title: '描述',
                                mode: "popup",
                                emptytext: "--"
                                url:'/edit_todo',
                                success: function(response, newValue) {
                                    if(response=='nouser'){
                                        return "请先登录!";
                                    }
                                    if(response=='7'){
                                        return "对不起,您无此操作权限!";
                                    }
                                    if(response.status =='error') {
                                        return response.msg;
                                    }
                                }
                            }
                        }

另一种在onEditableSave 中进行编辑保存,例如:

onEditableSave: function (field, row, oldValue,$el) {

                $.ajax({
                    type: "post",
                    url: "/edit_todo",
                    data: {
                        "pk":row.id,
                        "name":field,
                        "oldValue":oldValue,
                        "newValue":row[field]
                    },
                    success: function(data, status) {
                        if(status=='success'){
                            if (data == "nouser") {
                               return "请先登陆";                                 
                        }
                        if(data=='notallowed') {

                            return "对不起,您无此操作权限!";
                           
                        }
                        if(data=='exHigh' || data == 'Unresolved'|| data=='bug'){     //控制颜色显示
                            $el.css("backgroundColor", "");
                            $el.removeClass("PinkBackground");
                            $el.removeClass("blueBackground");
                            $el.removeClass("greyBackground");
                            $el.addClass("redBackground");
                        }
                        else if(data=='High'){
                            $el.css("backgroundColor", "");
                            $el.removeClass("redBackground");
                            $el.removeClass("blueBackground");
                            $el.addClass("PinkBackground");

                        }

                        else {
                            $el.css("backgroundColor", "");
                            $el.removeClass("redBackground");
                            $el.removeClass("greyBackground");
                            $el.removeClass("PinkBackground");
                            $el.removeClass("blueBackground");
                        }
                    }
                        },

                    error: function () {
                        return'编辑失败';
                    },
                    complete: function () {

                    }
  

问题一:在方法二中可以直接读取oldValue的值,而在方法一中,转到后台方法的参数名固定是name,value,pk, 有没有什么办法可以将oldValue也传入;
问题二:在onEditableSave success回调时,我需要进行错误信息的提示,如图:

clipboard.png
此功能在方法一中可以实现,在方法二中却无法实现;
请问如何在方法二中也出现提示提示信息的显示呢??

撰写答案