How to close create and edit window in after submitting in data table editor?

How to close create and edit window in after submitting in data table editor?

PShanmugasunPShanmugasun Posts: 1Questions: 1Answers: 0
edited June 2019 in Free community support
 var ProcessName = 'All';
    var editor; 
    var url = '@Url.Action("GetProcessCategoryList", "Pnl")?ProcessName=' + ProcessName;
    var urlAction = '@Url.Action("SaveProcessCategory", "Pnl")';
    $(document).ready(function () {
        editor = new $.fn.dataTable.Editor({
            //ajax: urlAction, 
            table: "#example",
            idSrc: 'Process_Category_ID',
            fields: [
                {
                    label: "Process Name:",
                    name: "ProcessName"
                }, 

                {
                    label: "Process Category:",
                    name: "ProcessCategory"
                }, 
                {
                    label: "Is Active:",
                    name: "IsActive",
                    type: "select",
                    options: [
                        { label: "Active", value: "Active"},
                        { label: "In Active", value: "In Active" }
                    ]
                }
            ],


            ajax: function (method, url, d, successCallback, errorCallback) {
                
                var output = { data: [] };
                
                if (d.action === 'create') {     
                    $.each(d.data, function (key, value) {
                        var id = key;
                        value.DT_RowId = id;
                        console.log(value);
                        output=value;
                    });
                    
                }
                else if (d.action === 'edit') {
                    $.each(d.data, function (id, value) {
                        value.DT_RowId = id;
                        output=value;
                    });
                }
                else if (d.action === 'remove') {
             
                    $.each(d.data, function (id, value) {
                        value.DT_RowId = id;
                        output = value;
                    });             
                };
                console.log(output);
                $.ajax({
                    url: urlAction,
                    dataType: "json",
                    type: 'POST',
                    data: { action: d.action, processname: output.ProcessName, processcategory: output.ProcessCategory, isactive: output.IsActive, id: output.DT_RowId },
                    success: function (data) {
                      }
                });

               
            }
        });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @PShanmugasun ,

    I'm not following, sorry, as that's the default behaviour with Editor - the edit and create forms always close after submission, see here.

    Could you give more explanation, please.

    Cheers,

    Colin

This discussion has been closed.