Edits With Same Controller But Different Editors Not Working

Edits With Same Controller But Different Editors Not Working

samevedzisamevedzi Posts: 30Questions: 5Answers: 0

Hi,

Kindly help with the following:

I have a controller which is accessed from two different views. The editor in the first one is allowed to edit some fields whiles the second can modify all fields.

My issue is that edits from the first view works fine but not the second. They both do not return any errors. The Controller and the Form Data for first and second interfaces are shown below:

Controller:

                var formData = HttpContext.ApplicationInstance.Context.Request;
                var settings = iSource_Editor.Properties.Settings.Default;

                using (var db = new Database(settings.DbType, settings.DbConnection))
                {
                    int Vendor_ID = User_ID;
                    string Vendor_ID_Operator = "=";
                    string User_Type = (string)Session["UserType"];

                    if (User_Type.Equals("Sourcing"))
                    {
                        Vendor_ID = 0;
                        Vendor_ID_Operator = ">";
                    }

                    Editor editor = new Editor(db, "Vendor", "ID")
                        .Model<Vendor>("Vendor")
                        .Where("ID", Vendor_ID, Vendor_ID_Operator)
                        .Field(new Field("Reset_Password").Set(Field.SetType.Create).SetValue(1))
                        .Field(new Field("CreatedBy").Set(Field.SetType.Create).SetValue(Vendor_ID))
                        .Field(new Field("CreatedDate")
                            .Set(Field.SetType.Create).SetValue(DateTime.Now)
                            .GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
                            .SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
                        )
                        .Field(new Field("ModifiedBy").Set(Field.SetType.Both).SetValue(Vendor_ID))
                        .Field(new Field("ModifiedDate")
                            .Set(Field.SetType.Both).SetValue(DateTime.Now)
                            .GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
                            .SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
                        )                     
                        //TO DO: TO REMOVE .Debug(true) LINE AFTER DEBUGGING
                        .Debug(true);

                    //Return response to view
                    DtResponse response = editor.Process(formData).Data();
                    return Json(response, JsonRequestBehavior.AllowGet);
                }

Form Data - First Interface:

data%5Brow_2359%5D%5BVendor%5D%5BUsername%5D=HOL&data%5Brow_2359%5D%5BVendor%5D%5BName%5D=Holman+Consulting+Ltd&data%5Brow_2359%5D%5BVendor%5D%5BContact_Person_Email_address%5D=stephen.amevedzi%40gmail.com&data%5Brow_2359%5D%5BVendor%5D%5BActive%5D=true&action=edit

Form Data - Second Interface:

data%5Bkeyless%5D%5BVendor%5D%5BTitle%5D=0&data%5Bkeyless%5D%5BVendor%5D%5BName%5D=Holman+Consulting+Ltd&data%5Bkeyless%5D%5BVendor%5D%5BPhysical_Address%5D=1st+Floor+Maxsony+Plaza%2C+No+37+Okodan+Street+Osu&data%5Bkeyless%5D%5BVendor%5D%5BPostal_Address%5D=LG+29+Legon&data%5Bkeyless%5D%5BVendor%5D%5BTelephone%5D=0246143912++++&data%5Bkeyless%5D%5BVendor%5D%5BFax%5D=1234567890&data%5Bkeyless%5D%5BVendor%5D%5BContact_Person%5D=Kobina+Holman&data%5Bkeyless%5D%5BVendor%5D%5BContact_Person_Telephone%5D=0246143912&data%5Bkeyless%5D%5BVendor%5D%5BContact_Person_Email_address%5D=stephen.amevedzi%40gmail.com+&data%5Bkeyless%5D%5BVendor%5D%5BWeb_address%5D=www.holmanconsultinggh.com&data%5Bkeyless%5D%5BVendor%5D%5BNature_of_Business%5D=1&data%5Bkeyless%5D%5BVendor%5D%5BBusiness_type%5D=3&data%5Bkeyless%5D%5BVendor%5D%5BTax_Number%5D=C0061005789&data%5Bkeyless%5D%5BVendor%5D%5BRegistration%5D=BNOOZMB2015&data%5Bkeyless%5D%5BVendor%5D%5BRegistration_Date%5D=23%2F09%2F2015+12%3A00%3A00+pm&data%5Bkeyless%5D%5BVendor%5D%5BBankID%5D=20&data%5Bkeyless%5D%5BVendor%5D%5BBankBranchID%5D=1044&data%5Bkeyless%5D%5BVendor%5D%5BBanck_Account_Number%5D=201110439140&data%5Bkeyless%5D%5BVendor%5D%5BBank_Account_Name%5D=+HOLMAN+CONSULTING&data%5Bkeyless%5D%5BVendor%5D%5BGSB_Conform%5D=2&data%5Bkeyless%5D%5BVendor%5D%5BIQS_Conform%5D=2&data%5Bkeyless%5D%5BVendor%5D%5BWorking_Hours%5D=8am+-+5pm&action=edit

Thanks in advance,
---Stephen

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    &data%5Bkeyless%5D

    That suggests to me that the non-working table doesn't have the ID information. Is it a DataTable that you are editing data in on that one? If so, can you show me the configuration you are using for the DataTable and also the JSON response from the server for loading the data?

    Thanks,
    Allan

  • samevedzisamevedzi Posts: 30Questions: 5Answers: 0

    Hi Allan,

    Thanks for the quick response.

    The final solution does not use a DataTable but I tried that as well but same problem.

    When the page loads, we pick the profile details of the vendor who has logged in and present in a panel using the Panel Creation Function. When the vendor clicks on the edit button, we call up the editor. The various code scrips are below.

    Panel Creation Function

    function CreatePanel(data) {
            var id = data.DT_RowId;
            //Update these variables after getting the data
            Business_Type = data.Vendor.Business_type;
            Business_Nature = data.Vendor.Nature_of_Business;
    
            $(
                '<div  class="col-md-12" data-editor-id="' + id + '">' +
                '<dl>' +
                '<div class="">' +
                '<div class="col-sm-12">' +
                '<div class="col-xs-12 col-sm-12">' +
                '<span data-editor-field="Vendor.Title" hidden> ' + data.Vendor.Title + '</span >' +
                '<span id="Title">' + (data.Vendor.Title == 0 ? "N/A" :
                    (data.Vendor.Title == 1 ? "Mr" :
                        (data.Vendor.Title == 2 ? "Mrs" :
                            (data.Vendor.Title == 3 ? "Miss" :
                                (data.Vendor.Title == 4 ? "Dr" :
                                    (data.Vendor.Title == 5 ? "Prof" : "Other")))))) + '</span>' +
                '<h2 id="Name" data-editor-field="Vendor.Name" style="font-weight: bold;">' + data.Vendor.Name + '</h2>' +
                '<div class="col-sm-12">' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-location-arrow"></i> Postal Address:</dt>' +
                '<p id="Postal_Address" data-editor-field="Vendor.Postal_Address">' + data.Vendor.Postal_Address + '</p>' +
                '</div>' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-map-marker"></i> Physical Address:</dt>' +
                '<p id="Physical_Address" data-editor-field="Vendor.Physical_Address"> ' + data.Vendor.Physical_Address + '</p>' +
                '</div>' +
                '</div>' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-phone"></i> Telephone:</dt>' +
                '<p id="Telephone" data-editor-field="Vendor.Telephone">' + data.Vendor.Telephone + '</strong> </p>' +
                '</div>' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-fax"></i> Fax Number:</dt>' +
                '<p id="Fax" data-editor-field="Vendor.Fax">' + data.Vendor.Fax + '</p>' +
                '</div>' +
                '</div>' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-user"></i> Contact Person:</dt>' +
                '<p id="Contact_Person" data-editor-field="Vendor.Contact_Person">' + data.Vendor.Contact_Person + '</p>' +
                '</div>' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-mobile"></i> Contact Person Telephone:</dt>' +
                '<p id="Contact_Person_Telephone" data-editor-field="Vendor.Contact_Person_Telephone">' + data.Vendor.Contact_Person_Telephone + '</p>' +
                '</div>' +
                '</div>' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-envelope"></i> Email Address:</dt>' +
                '<p id="Contact_Person_Email_address" data-editor-field="Vendor.Contact_Person_Email_address">' + data.Vendor.Contact_Person_Email_address + '</strong> </p>' +
                '</div>' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-globe"></i> Web address:</dt>' +
                '<p id="Web_address" data-editor-field="Vendor.Web_address">' + data.Vendor.Web_address + '</p>' +
                '</div>' +
                '</div>' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-briefcase"></i> Nature of Business:</dt>' +
                '<p id="Nature_of_Business" data-editor-field="Vendor.Nature_of_Business" hidden>' + data.Vendor.Nature_of_Business + '</p>' +
                '<p id="NatureOfBusinessDescription">' + (data.Vendor.Nature_of_Business == 0 ? "Other" :
                    (data.Vendor.Nature_of_Business == 1 ? "Manufacturer" :
                        (data.Vendor.Nature_of_Business == 2 ? "Authorised Agent" :
                            (data.Vendor.Nature_of_Business == 3 ? "Reseller" :
                                (data.Vendor.Nature_of_Business == 4 ? "Health Agent" :
                                    (data.Vendor.Nature_of_Business == 5 ? "Medical Practitioner" :
                                        (data.Vendor.Nature_of_Business == 6 ? "Coordinator" : "Broker"))))))) + '</p>' +
                '</div>' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-building"></i> Business type:</dt>' +
                '<p id="Business_type" data-editor-field="Vendor.Business_type" hidden>' + data.Vendor.Business_type + '</p>' +
                '<p id="BusinessTypeDescription">' + (data.Vendor.Business_type == 0 ? "Unregistered" :
                    (data.Vendor.Business_type == 1 ? "Enterprise" :
                        (data.Vendor.Business_type == 2 ? "Partnership" :
                            (data.Vendor.Business_type == 3 ? "Limited Liability" :
                                (data.Vendor.Business_type == 4 ? "Subsidiary" : NGO))))) + '</p>' +
                '</div>' +
                '</div>' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-barcode"></i> Tax Identification Number:</dt>' +
                '<p id="Tax_Number" data-editor-field="Vendor.Tax_Number">' + data.Vendor.Tax_Number + '</p>' +
                '</div>' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-list-ol"></i> Company Registration Number:</dt>' +
                '<p id="Registration" data-editor-field="Vendor.Registration">' + data.Vendor.Registration + '</p>' +
                '</div>' +
                '</div>' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-calendar"></i> Company Registration Date</dt>' +
                '<p id="Registration_Date" data-editor-field="Vendor.Registration_Date">' + data.Vendor.Registration_Date + '</p>' +
                '</div >' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-user"></i> Bank Name</dt>' +
                '<p id="Bank" data-editor-field="Vendor.BankID" hidden>' + data.Vendor.BankID + '</p>' +
                '<p id="BankDescription">' + data.Bank.Description + '</p>' +
                '</div >' +
                '</div >' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-university"></i> Bank Branch</dt>' +
                '<p id="BankBranch" data-editor-field="Vendor.BankBranchID" hidden>' + data.Vendor.BankBranchID + '</p>' +
                '<p id="BankBranchDescription">' + data.BankBranch.BankBranchDescription + '</p>' +
                '</div >' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-sort-numeric-asc"></i> Banck Account Number</dt>' +
                '<p id="Banck_Account_Number" data-editor-field="Vendor.Banck_Account_Number">' + data.Vendor.Banck_Account_Number + '</p>' +
                '</div >' +
                '</div >' +
    
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-sort-alpha-asc"></i> Bank Account Name</dt>' +
                '<p id="Bank_Account_Name" data-editor-field="Vendor.Bank_Account_Name">' + data.Vendor.Bank_Account_Name + '</p>' +
                '</div >' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-check"></i> Ghana Standard Board Approved</dt>' +
                '<p id="GSB_Conform" data-editor-field="Vendor.GSB_Conform" hidden>' + data.Vendor.GSB_Conform + '</p>' +
                '<p id="GSB_Conform_Description">' + (data.Vendor.GSB_Conform === 2 ? 'Yes' : (data.Vendor.GSB_Conform === 1 ? 'No' : 'N/A')) + '</p>' +
                '</div >' +
                '</div >' +
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-check-circle"></i> International Quality Standards Approved</dt>' +
                '<p id="IQS_Conform" data-editor-field="Vendor.IQS_Conform" hidden>' + data.Vendor.IQS_Conform + '</p>' +
                '<p id="IQS_Conform_Description">' + (data.Vendor.IQS_Conform === 2 ? 'Yes' : (data.Vendor.IQS_Conform === 1 ? 'No' : 'N/A')) + '</p>' +
                '</div >' +
                '<div class="row">' +
                '<div class="col-sm-6">' +
                '<dt><i class="fa fa-check-circle"></i> Working Hours (Eg. 8am - 5pm)</dt>' +
                '<p id="Working_Hours" data-editor-field="Vendor.Working_Hours">' + data.Vendor.Working_Hours + '</p>' +
                '</div >' +
                '<div class="col-sm-12"">' +
                '<button class="btn edit btn-primary btn-block" data-id="' + id + '"><i class="fa fa-pencil"></i> Edit</button>' +
                '</div>' +
                '</div >' +
                '</div >' +
                '</div >' +
                '</div >' +
                '</div >' +
                '</dl>' +
                '</div>'
            ).appendTo('#Panel_Profile');
        }
    

    Thanks,
    ---Stephen

  • samevedzisamevedzi Posts: 30Questions: 5Answers: 0

    The other scripts are as follows:

    Ajax To Load Vendor Profile

            $.ajax({
                url: '/Vendors/Profile',
                dataType: 'json',
                success: function (json) {
                    if (json.data.length > 0) {
                        CreatePanel(json.data[0]);
                    }
                }
            });
    

    On Panel Button Click

            $('#Panel_Profile').on('click', 'button.edit', function () {
                Editor_Profile.edit($(this).data('ID'), {
                    title: 'Edit Profile',
                    buttons: 'Save Changes'
                });
            });
    

    Editor:

            Editor_Profile = new $.fn.dataTable.Editor({
                ajax: "/Vendors/Profile",
                type: 'POST',
                idSrc: 'ID',
                fields: [
                    {
                        label: "Title:", name: "Vendor.Title", type: "select",
                        options: [
                            { label: "N/A", value: 0 },
                            { label: "Mr", value: 1 },
                            { label: "Mrs", value: 2 },
                            { label: "Miss", value: 3 },
                            { label: "Dr", value: 4 },
                            { label: "Prof", value: 5 },
                            { label: "Other", value: 6 }
                        ]
                    },
                    { label: "Name:", name: "Vendor.Name" },
                    { label: "Physical Address", name: "Vendor.Physical_Address" },
                    { label: "Postal Address", name: "Vendor.Postal_Address" },
                    { label: "Telephone", name: "Vendor.Telephone" },
                    { label: "Fax", name: "Vendor.Fax" },
                    { label: "Contact Person:", name: "Vendor.Contact_Person" },
                    { label: "Contact Person Telephone:", name: "Vendor.Contact_Person_Telephone" },
                    { label: "Email Address:", name: "Vendor.Contact_Person_Email_address" },
                    { label: "Web address:", name: "Vendor.Web_address" },
                    {
                        label: "Nature of Business:", name: "Vendor.Nature_of_Business", type: "select",
                        options: [
                            { label: "Other", value: 0},
                            { label: "Manufacturer", value: 1 },
                            { label: "Authorised Agent", value: 2 },
                            { label: "Reseller", value: 3 },
                            { label: "Health Agent", value: 4 },
                            { label: "Medical Practitioner", value: 5 },
                            { label: "Coordinator", value: 6 },
                            { label: "Broker", value: 7 }
                        ]
                    },
                    {
                        label: "Type of Business:", name: "Vendor.Business_type", type: "select",
                        options: [
                            { label: "Unregistered", value: 0 },
                            { label: "Enterprise", value: 1 },
                            { label: "Partnership", value: 2 },
                            { label: "Limited Liability", value: 3 },
                            { label: "Subsidiary", value: 4 },
                            { label: "NGO", value: 5}
                        ]
                    },
                    { label: "Tax Identification Number", name: "Vendor.Tax_Number" },
                    { label: "Registration Number", name: "Vendor.Registration" },
                    {
                        label: "Registration Date",
                        name: "Vendor.Registration_Date",
                        type: 'datetime',
                        def: function () { return new Date(); },
                        format: 'YYYY-MM-DD',
                        fieldInfo: 'Standard style y-m-d date input'
                    },
                    { label: "Select Bank:", name: "Vendor.BankID" },
                    { label: "Select Branch:", name: "Vendor.BankBranchID" },
                    { label: "Banck Account Number", name: "Vendor.Banck_Account_Number" },
                    { label: "Bank Account Name", name: "Vendor.Bank_Account_Name" },
                    {
                        label: "Ghana Standard Board Approved?", name: "Vendor.GSB_Conform", type: "select",
                        options: [
                            { label: "N/A", value: 0 },
                            { label: "No", value: 1 },
                            { label: "Yes", value: 2 }
                        ]
                    },
                    {
                        label: "International Quality Standards Approved", name: "Vendor.IQS_Conform", type: "select",
                        options: [
                            { label: "N/A", value: 0 },
                            { label: "No", value: 1 },
                            { label: "Yes", value: 2 }
                        ]
                    },
                    { label: "Working Hours (Eg. 8am - 5pm)", name: "Vendor.Working_Hours" }
                ]
            });
    

    Please, can you also suggest a better way, if there is one, to get this done.

    Thanks,
    ---Stephen

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    data-id

    But:

    $(this).data('ID')

    That case difference might be the issue. I've just tried a little experiment and it does appear to make a difference:

    Allan

  • samevedzisamevedzi Posts: 30Questions: 5Answers: 0

    Hi Allan,

    Thanks once again for the response.

    I am happy to inform that I have tried your suggestion and it worked.

    Unfortunately, I have an associated issue coming up. The delete button of the DataTable below the Panel does not work most of the time. The delete confirmation window pops up but when you click on the 'Delete' button at the button right of the window, no action happens. The associates scripts are below.

    <script>
    
        var DataTable_Vendor;
        var Editor_Profile;
        var DataTable_ContractDocument;
        var Profile_Options_Banks;
        var RequireIssuedDate;
        var RequireExpiryDate;
        var Business_Type;
        var Business_Nature;
        var Document_Name;
    
        function ApplyDocumentValidation() {
            //Documents Validation
            var Has_Required_Doc = false;
    
            //--Unregistered Businesses
            if (Business_Type == 0) {
                if (Business_Nature == 4) {
                    Document_Name = "NHIS Authorization Letter";
                }
                else if (Business_Nature == 5) {
                    Document_Name = "Practicing License";
                }
                else {
                    Document_Name = "CV";
                }
            }
            //--Registered Business
            else {
                if (Business_Type == 3 || Business_Type == 5) {
                    Document_Name = "Certificate Of Incorporation";
                }
                else if (Business_Type == 1 || Business_Type == 2 || Business_Type == 4) {
                    Document_Name = "Certificate Of Registration";
                }
            }
    
            //Validation
            DataTable_ContractDocument.rows().data().each(function (value, index) {
                if (value.Contract_Doc_Name.Description == Document_Name) {
                    Has_Required_Doc = true;
                }
            });
    
            //Feedback to User
            if (!Has_Required_Doc) {
                $('#Required_Documents_Message').html(Document_Name + " is required.");
            }
            else {
                $('#Required_Documents_Message').html("");
            }
        }
    
        $(document).ready(function () {
            Editor_ContractDocument = new $.fn.dataTable.Editor({
                ajax: {
                        url: "/Vendors/Contract_Doc_Vendor",
                        type: "post",
                        data: function (d) {
                            d.Vendor_ID = @Session["ID"];
                        }
                },
                table: "#Table_ContractDocument",
                fields: [
                    { label: "Contract_Doc_Name:", name: "Contract_Doc_Vendor.Contract_Doc_Name_ID", type: "select", placeholder: "Select a Contract Doc Name" },
                    {
                        label: "Attachment:", name: "Contract_Doc_Vendor.File_ID",
                            type: "upload",
                        display: function (File_ID) {
                            return '<a href="' + Editor_ContractDocument.file('File_Upload', File_ID).Web_Path + '" target="_blank">File</a>';
                            },
                            clearText: "Clear",
                        noImageText: 'No image'
                    },
                    {
                        label: "Issued Date:", name: "Contract_Doc_Vendor.Issued_Date", type: 'datetime'
                    },
                    { label: "Expiry Date:", name: "Contract_Doc_Vendor.Expiry_Date", type: 'datetime' },
                    {
                        label: "Active:", name: "Contract_Doc_Vendor.Active", type: "select",
                        options: [
                            { label: "Yes", value: "1" },
                            { label: "No", value: "0" }
                        ]
                    }
                ]
            });
            Editor_ContractDocument
                //Force Retrieval of Issued Date/Expiry Date
                .dependent('Contract_Doc_Vendor.Contract_Doc_Name_ID',
                    function (val) {
                        if (val > 0) {
                            $.ajax({
                                url: '/ContractDocuments/GetDefaultValues',
                                dataType: 'json',
                                data: {
                                    ContractDocument_ID: val
                                },
                                success: function (json) {
                                    //Set and disable Cost field
                                    RequireIssuedDate = json.RequireIssuedDate;
                                    RequireExpiryDate = json.RequireExpiryDate;
    
                                    if (!RequireIssuedDate) {
                                        Editor_ContractDocument.field("Contract_Doc_Vendor.Issued_Date").disable().val(null);
                                    } else {
                                        Editor_ContractDocument.field("Contract_Doc_Vendor.Issued_Date").enable();
                                    }
    
                                    if (!RequireExpiryDate) {
                                        Editor_ContractDocument.field("Contract_Doc_Vendor.Expiry_Date").disable().val(null);
                                    } else {
                                        Editor_ContractDocument.field("Contract_Doc_Vendor.Expiry_Date").enable();
                                    }
                                }
                            });
                        }
                    }
                )
                //Validate before submission
                .on('preSubmit', function (e, o, action) {
                    // If any error was reported, cancel the submission so it can be corrected
                    if (!Editor_ContractDocument.field("Contract_Doc_Vendor.File_ID").val()) {
                        Editor_ContractDocument.field("Contract_Doc_Vendor.File_ID").error('Attachment is required');
                        return false;
                    }
                    if (RequireIssuedDate && !Editor_ContractDocument.field("Contract_Doc_Vendor.Issued_Date").val()) {
                        Editor_ContractDocument.field("Contract_Doc_Vendor.Issued_Date").error('Issued Date is required');
                        return false;
                    }
                    if (RequireExpiryDate && !Editor_ContractDocument.field("Contract_Doc_Vendor.Expiry_Date").val()) {
                        Editor_ContractDocument.field("Contract_Doc_Vendor.Expiry_Date").error('Expiry Date is required');
                        return false;
                    }
                });
            DataTable_ContractDocument = $('#Table_ContractDocument').DataTable({
                dom: "Bfrtip",
                ajax: {
                    url: "/Vendors/Contract_Doc_Vendor",
                    data: function (d) {
                        d.Vendor_ID = @Session["ID"];
                    }
                },
                order: [[1, 'asc']],
                columns: [
                    {
                        data: null,
                        defaultContent: '',
                        className: 'select-checkbox',
                        orderable: false
                    },
                    { "data": "Contract_Doc_Name.ID", visible: false },
                    { "data": "Contract_Doc_Name.Description", "autowidth": true, visible: true },
                    {
                        "data": "Contract_Doc_Vendor.File_ID", "autowidth": true, visible: true,
                        render: function (File_ID) {
                            return File_ID ? '<a href="' + Editor_ContractDocument.file('File_Upload', File_ID).Web_Path + '" target="_blank">File</a>' : 'No file';
                        },
                        defaultContent: "No image",
                        title: "File"
                    },
                    { "data": "Contract_Doc_Vendor.Issued_Date", "autowidth": true, visible: true },
                    { "data": "Contract_Doc_Vendor.Expiry_Date", visible: true },
    
                    {
                        "data": "Contract_Doc_Vendor.Active", "render": function (val, type, row) {
                            return val == 0 ? "No" : "Yes";
                        }
                    },
                    { "data": "Contract_Doc_Vendor.Approved", render: function (val, type, row) {
                            return val == 0 ? "No" : "Yes";
                        } },
                    { "data": "Contract_Doc_Vendor.Approved_Date", visible: true }
                ],
                select: true,
                buttons: [
                    { extend: "create", editor: Editor_ContractDocument, text: 'Add' },
                    { extend: "edit", editor: Editor_ContractDocument },
                    { extend: "remove", editor: Editor_ContractDocument },
                    {
                        extend: 'collection',
                        text: 'Export',
                        buttons: [
                            'excel',
                            'csv',
                            'pdf',
                            'print'
                        ]
                    }
                ]
            });
            DataTable_ContractDocument.on('draw', function () {
                //Documents Validation
                ApplyDocumentValidation();
            });
    

    Thanks,
    ---Stephen

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi Stephen,

    Is the Ajax request to the server for the delete action made? You'd be able to see it in the browsers "Network" inspector panel.

    I think I'd need a link to your page to be able to help debug this one fully.

    Allan

  • samevedzisamevedzi Posts: 30Questions: 5Answers: 0

    Hi Allan,

    Thanks for the response once again.

    No, the Ajax request to the server for the delete action is not made at all.

    I have also noticed that the DataTable loads with a default value in the search box which filters the DataTable ones it loads. The following is the screenshot (https://datatables.net/forums/uploads/editor/8q/brr017bqxqmh.png ""). Could this be a factor? How do I take it out?

    The app is offline now. Would you want to come in remotely?

    Thanks,
    ---Stephen

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    There is nothing in the code above that would cause a default search value. Perhaps you have state saving enabled somewhere? That shouldn't cause any issues with the delete submission though.

    You are using preSubmit - my guess is that the event is returning false for the remove action. Try adding:

    if (action === 'remove') {
      return;
    }
    

    at the top of that function.

    Allan

  • samevedzisamevedzi Posts: 30Questions: 5Answers: 0

    Hi Allan,

    I'm happy to inform you that your suggestion worked.

    Also, the default filtering was happening because of saved passwords; once I removed the saved passwords, the filtering stopped.

    Thanks so much for your assistance.
    ---Stephen

Sign In or Register to comment.