Form not updating data

Form not updating data

nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

Hello, I am using: https://datatables.net/release-datatables/examples/api/row_details.html and wanted to add a field to update. Everything loads fine but when I hit update, nothing changes in the db. I looked at the debugging tool and it looks like client_billedxxxxxx instead of client_billed=xxxxxx

    $(document).ready(function () {
        editor = new $.fn.dataTable.Editor({
            "ajax": "/api/cdi_master",
            "table": "#example",
            "fields": [  
            {
                label: "Client Billed:",
                name: "cdi_details.cdi_master_id",
                type: "radio",
                options: [
                    { label: "Yes", value: 1 },
                    { label: "No", value: 0 }
                ],
                "default": 1
            },
            ]
        });

Replies

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2
    edited August 2016
            /* Formatting function for row details - modify as you need */
    
            function format ( d ) {
    
                // `d` is the original data object for the row
    
                return '<table cellpadding="5" cellspacing="0" style="padding-left:50px;padding-bottom:50px">'+
                    '<tr>' +
    
                       
    
                '<td><B>CDI DETAILS...</B></td>' + '<td>&nbsp;</td>' + '<td>&nbsp;</td>' + '<td>&nbsp;</td>' + '<td>&nbsp;</td>' +
       '<td><B>STATUS AUDIT...</B></td>' +
                    '</tr>' +
                    '<tr>' +
                  
    
                        '<td>Simon:</td><td> ' + d.cdi_master.simon + '</td><td>Service Date: ' + d.cdi_master.service_date + '</td>' +
    
                '<td>Total Time Billed:</td><td>' + d.cdi_details.time + '</td>' +
                   '<td bgcolor=e8f4f8>Billed: ' + d.cdi_details.client_billed + '</td>' +
                    '</tr>'+
    
                    '<tr>' +
                    '<td>Group Count:</td><td> ' + d.cdi_details.group_count + '</td>' +
    
                        '<td>EBT:'+ d.cdi_details.ebt + '</td>'+
    
                        '<td>Location:</td><td valign=left>' + d.cdi_details.location + '</td>' 
                   +
                    '<td bgcolor=e8f4f8>Ineligible: ' + d.cdi_details.client_ineligible + '</td>' +
                    '</tr>'
                +
    
                    '<tr>' +
    
                        '<td>Itinerary:</td>' +
    
                        '<td>' + d.cdi_details.mileagestring + '</td>'
                    +
                    '<td>Total Mileage:</td> ' + '<td>' + d.cdi_details.totalmileage + '</td>'
                + '<td> &nbsp;</td>'  +
                    '<td bgcolor=e8f4f8>Audited: ' + d.cdi_details.client_audited + '</td>' +
                '</tr>' +
                    '<tr>'+
    
                        '<td>Co-Biller 1:</td>'+
    
                        '<td>'+ d.cdi_details.cb1_string + '</td>'
    
                +
    
                        '<td>Co-Biller 2:</td>' +
    
                        '<td>' + d.cdi_details.cb2_string + '</td>' 
    
                       +
                    '<td>&nbsp;</td>' + 
                        '<td bgcolor=e8f4f8>Researched: ' + d.cdi_details.client_research + '</td>'
                '</tr>'
    
                '</table>';
    
            }
    
    
            var editor; // use a global for the submit and return data rendering in the examples
    
            $(document).ready(function () {
                editor = new $.fn.dataTable.Editor({
                    "ajax": "/api/cdi_master",
                    "table": "#example",
                    "fields": [  
                    {
                        label: "Client Billed:",
                        name: "cdi_details.cdi_master_id",
                        type: "radio",
                        options: [
                            { label: "Yes", value: 1 },
                            { label: "No", value: 0 }
                        ],
                        "default": 1
                    },
                    ]
                });
                   
                
                // Update Billing
    
                $('#example').on('click', 'a.editor_edit', function (e) {
    
                    e.preventDefault();
    
     
    
                    editor.edit( $(this).closest('tr'), {
    
                        title: 'Update Billing Information',
                        message: 'You will be adding a billing record for this CDI. After you have completed, click Save',
    
                    buttons: 'Update'
    
                } );
    
                });
              
                var table = $('#example').DataTable( {
                    ajax: "/api/cdi_master",
    
                    "columns": [
    
                        {
    
                            "className":      'details-control',
                            "orderable":      false,
    
                            "data":           null,
    
                            "defaultContent": ''
    
                        }, { data: "cdi_details.client_num" },
                          { data: "cdi_details.kindid" },
            
                            { data: "cdi_details.cdi_master_id" },
                           { data: "cdi_details.name" },
                           { data: "cdi_master.ClinicianName" },
                     
                           { data: "cdi_details.service_class" },
                            { data: "cdi_details.service" },
                            {
                                "class": "left",
                                "data": "cdi_master.cdi_status_id",
                                "render": function (val, type, row) {
                                    return val == 4 ? "Completed" : val == 5 ? "Needs Research" : val == 1 ? "To Be Processed" : val == 2 ? "Recalled" : val == 6 ? "In Progress" : val == 3 ? "Needs Attention" : ""
                                }
                            },
                             {
    
                                 data: null, 
    
                                 className: "center",
    
                                 defaultContent: '<a href="" class="editor_edit">Update Billing</a>'
    
                             }
    
                    ]
                })
         
    
            // Add event listener for opening and closing details
    
            $('#example tbody').on('click', 'td.details-control', function () {
    
                var tr = $(this).closest('tr');
    
                var row = table.row( tr );
    
     
    
                if ( row.child.isShown() ) {
    
                    // This row is already open - close it
    
                    row.child.hide();
    
                    tr.removeClass('shown');
    
                }
    
                else {
    
                    // Open this row
    
                    row.child( format(row.data()) ).show();
    
                    tr.addClass('shown');
    
                }
    
            } );
    
            } );
    
           
    
    
        </script>
    

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

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Could you give me a link to the page showing the issue so I can debug it please?

    Thanks,
    Allan

This discussion has been closed.