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

问题描述

使用 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 (将#修改为@)