Multi-row bulk editing is not retaining the original values for untouched 'multi value' fields

Multi-row bulk editing is not retaining the original values for untouched 'multi value' fields

AVHtechAVHtech Posts: 7Questions: 3Answers: 1

For some reason Multi-row bulk editing is not retaining the original values for 'multi value' fields. When I select multiple rows the edit form shows a couple of fields as having "Multiple values". If I change one of the fields and submit that field value is applied to all selected records and the other 'Multiple values' fields are set to '0' (zero). I am not sure where to start looking for logs or the reason why the untouched fields are updating any values. Any help would be appreciated.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Can I just confirm, are you seeing the same behaviour with this example here? I tried it, and I believe it's working as expected.

    If so, could you post your Editor config code, please, both client-side and the server-side scripts.

    Colin

  • AVHtechAVHtech Posts: 7Questions: 3Answers: 1
    edited January 2023

    Thank you. The sample works.

    I believe this is the editor code. I noticed a difference between the sample code and my code is:

    SAMPLE CODE:

    formOptions: {
                main: {
                    scope: 'cell' // Allow multi-row editing with cell selection
                }
            }
    _My Code does not have this _
    

    SAMPLE CODE HAS: select: true,

    MY CODE:

    select: {
                    style:    'multi',
                    selector: 'td:first-child'
    }
    

    MY EDITOR CODE

    var editor = new $.fn.DataTable.Editor( {
            fixedHeader: true,
            ajax:  fetchOrigin + '/app/src/get-data.php?s=setJobsList&userType=' + userType + '&x=' + userId,
            paging: true,
            table: '#jobsDataTable',
            display: 'bootstrap',
            idSrc: 'Jobs.id',
    
            fields: [
                {label: 'Job Number', name: 'Jobs.id', type: 'readonly'},
                {label: 'Customer', name: 'Jobs.Company_Id', type: 'select'},
                {label: 'Location', name: 'Jobs.Location', type: 'select'},
                {label: 'Group Assigned', name: 'Jobs.Group_Assigned_To_Job', type: 'select'},
                {label: 'User Assigned', name: 'Jobs.User_Assigned_To_Job', type: 'select'},
                {label: 'Category', name: 'Jobs.Category', type: 'select'},
                {label: 'Status', name: 'Jobs.Status', type: 'select'},
                {label: 'Scheduled Date', name: 'Jobs.Scheduled_Date_Time', type: 'datetime'},
                {label: 'Reference Number', name: 'Jobs.Reference_Number'},
                {label: 'Address', name: 'Jobs.Address'},
                {label: 'City', name: 'Jobs.City'},
                {label: 'State', name: 'Jobs.State'},
                {label: 'Postal Code', name: 'Jobs.Postal_Code'},
                {label: 'Country', name: 'Jobs.Country'},
                {label: 'Contact Person', name: 'Jobs.Contact_Person'},
                {label: 'Email', name: 'Jobs.Contact_Person_Email'},
                {label: 'Mobile Phone', name: 'Jobs.Contact_Person_Mobile_Phone'},
                {label: 'Office Phone', name: 'Jobs.Contact_Person_Office_Phone'},
                {label: 'Job Description', name: 'Jobs.Description'},
                {label: 'Job Detail', name: 'Jobs.Detail', type: 'textarea'},
                {label: 'Comment', name: 'Jobs.Comment', type: 'textarea'}
            ]
        } );
    
        var jobsTable = $('#jobsDataTable').DataTable(
    
            {
            fixedHeader: true,          
                dom: 'Brtip', //removes search box for now 
                serverSide: true,
                processing: true,
                paging: true,
                search: false,
                searching: { regex: false },
                ajax: fetchOrigin + '/app/src/get-data.php?s=getJobsList&userType=' + userType + '&x=' + userId,
                
                columns: [
                    {
                        data: null,
                        defaultContent: '',
                        className: 'select-checkbox',
                        orderable: false
                    },
            { data: 'Jobs.id',
                    render: function(data, type, full, meta) {
                    return '<a href="view-job?num='+data+'">'+data+'</a>'}},
                    { data: 'Jobs.Company_Id' },
                    { data: 'Jobs.Location' },
                    { data: 'Jobs.Group_Assigned_To_Job' },
                    { data: 'Jobs.User_Assigned_To_Job' },
                    { data: 'Category.Name' }, // from Jobs.Category
                    { data: 'Status.Name' },
                    { data: 'Jobs.Scheduled_Date_Time'},
                    { data: 'Jobs.Reference_Number' },
                    { data: 'Jobs.Address' },
                    { data: 'Jobs.City' },
                    { data: 'Jobs.State' },
                    { data: 'Jobs.Postal_Code' },
                    { data: 'Jobs.Country' },
                    { data: 'Jobs.Contact_Person' },
                    { data: 'Jobs.Contact_Person_Email' },
                    { data: 'Jobs.Contact_Person_Mobile_Phone' },
                    { data: 'Jobs.Contact_Person_Office_Phone' },
                    { data: 'Jobs.Description' },
                    { data: 'Jobs.Detail' },
                    { data: 'Jobs.Comment' }
                ],
                order: [ 1, 'asc' ],
                select: {
                    style:    'multi',
                    selector: 'td:first-child'
                },
                buttons: [{ extend: 'edit',   editor: editor }, { extend: 'remove', editor: editor }, 'copy', 'csv', 'excel', 'pdf', 'print']
            }
        );
    

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

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    ajax:  fetchOrigin + '/app/src/get-data.php?s=setJobsList&userType=' + userType + '&x=' + userId,
    

    Can that script handle the multi-row editing format submitted by Editor? Are you using the Editor PHP libraries to write to the database or your own?

    If you could link to a test case showing the issue, that would be really useful.

    Allan

  • AVHtechAVHtech Posts: 7Questions: 3Answers: 1

    Thank you for the answer, I disabled the multi-edit for now. I will do further investigations later as it seems I am using a custom code, other tables that seem to use the Editor PHP libraries are working.

Sign In or Register to comment.