微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在编辑器数据表中未编辑编辑字段值后

如何解决在编辑器数据表中未编辑编辑字段值后

使用 jquery 数据表,当通过编辑器表单编辑字段的值时,不会在发布请求中发送更新的值,并且不会编辑列中的值。

编辑器 -

editor = new $.fn.dataTable.Editor( {
    ajax: "/example/",table: "#exampleTable",idSrc:  'id',fields: [
        {
            label: "Name",name: "market"
        },{ 
            label: 'Description',name: 'description' 
        },tags_editor_def("tags","/relation/tag/search/?oppty=true"),company_editor_def("company",false,"Partner"),{ 
            label: 'Stage',name: 'status',type:"select",def:'327'
        },{
            label: "Value",name: "value"
        },date_editor("Due","due_date",todayPlus14days),{
            label: "Favorite",name: "favorite",type: "checkBox",options: [
                {
                    'label': '','value': true
                }
            ]
        },{
            label: "Favorites",name: "favorites",type: "select2",opts: {
                multiple: true,placeholder: "",initialValue:true,ajax: {
                    url:"/users/search/",dataType:"json",delay: 250,data: select2_data_fn,},}
        },{
            label: "Owner",name: "responsable",type: "select",def: user_id
        },{
            label: "Notes",name: "notes",type: "textarea"
        }
    ]
});

数据表 -

var table = $('#opptyTable').DataTable( {
    dom: '<"bottom"Bfrtlip<"clear">>',stateSave: true,language: {
        lengthMenu: "_MENU_"
    },ajax: "/opportunities/",ordering: true,rowId:  'id',scrollX: true,createdRow: function( row,data,dataIndex ) {
        $(row).addClass( 'datatable-row' );
    },columns: [..]
});

预提交功能

editor.on( 'preSubmit',function ( e,action ) {
    data["data"] = JSON.stringify(data["data"])
    if (action !== 'remove') {
        var partner = this.field('company');
        if (!partner.isMultiValue()) {
            if (!partner.val()) {
                partner.error('required');
            }
        }
        if (this.inError()) {
            return false;
        }
    }
} );

如果我在 presubmit 中使用 console.log,则编辑后的值存在,但在 post 请求的网络选项卡中正在发送旧值

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。