Autofill Undefined Index with inline edit server side

Autofill Undefined Index with inline edit server side

ztaylor1990ztaylor1990 Posts: 27Questions: 10Answers: 0

I have been trying to figure out why I am getting this error with autofill. When I drag down on a row the autofill option menu opens after clicking "fill all cells with value" the menu closes and the table does not update. When I refresh the table every column to the right of the column I used the autofill on is zero.

Here is my code

//current working file Main1
function rfpworking() {
  $(document).ready(function() {
    var val = $('#project_name').val();
    var editor = new $.fn.dataTable.Editor( {
        
      "processing": true,
      "serverSide": true,
      "scrollX": true,
      ajax: {
        url: '../dependencies/datatables/php/rfpworking_table_serverside.php',
        "type": "POST",
        data: function ( d ) {
          d.val = val;
        }
      },
      "table": "#rfpworking",
        
      fields: [ {
        label: "Origin City",
        name: "origin_city"
      }, {
        label: "Origin State",
        name: "origin_state"
      }, {
        label: "Destination City",
        name: "destination_city"
      }, {
        label: "Destination State",
        name: "destination_state"
      }, {
        label: "Truck Type",
        name: "truck_type"
      }, {
        label: "Companies",
        name: "spot_num_companies"
      }, {
        label: "Reports",
        name: "spot_num_reports"
      }, {
        label: "Our Avg LH",
        name: "our_avg_lh"
      }, {
        label: "Our Num Reports",
        name: "our_num_reports"
      }, {
        label: "Ann Volume",
        name: "ann_volume"
      }, {
        label: "Cust Miles",
        name: "cust_miles"
      }, {
        label: "Market Avg LH Dat",
        name: "market_avg_lh_dat"
      }, {
        label: "DAT Miles",
        name: "dat_miles"
      },{
        label: "Avg RPM",
        name: "avg_rpm"
      }, {
        label: "Carrier Fuel",
        name: "carrier_fuel"
      }, {
        label: "Cust Fuel",
        name: "cust_fuel"
      }, {
        label: "Margin %",
        name: "percent_margin"
      }, {
        label: "Margin Flat:",
        name: "margin_flat"
      }, {
        label: "Cust Flat",
        name: "cust_flat"
      }, {
        label: "Cust All In",
        name: "cust_all_in"
      }, {
        label: "Carrier Flat",
        name: "carrier_flat"
      }, {
        label: "Carrier All In",
        name: "carrier_all_in"
      }, {
        label: "All In GP",
        name: "all_in_gp"
      },{
        label: "GP %",
        name: "gp_percent"
      },{
        label: "Spot Low",
        name: "spot_low"
      }, {
        label: "Spot High",
        name: "spot_high"
      }, {
        label: "STD",
        name: "std"
      }, {
        label: "Time",
        name: "time"
      }, {
        label: "Hazmat (Yes)",
        name: "hazmat"
      },{
        label: "Lane ID",
        name: "lane_id"
      },{
        label: "extra1",
        name: "extra1"
      },{
        label: "extra2",
        name: "extra2"
      },{
        label: "extra3",
        name: "extra3"
      },{
        label: "extra4",
        name: "extra4"
      }
      
      ]
    } );
    
    $('#rfpworking').on( 'click', 'tbody td', function (e) {
editor.inline(this, {
  submit: 'allIfChanged'
});
    } );
    


    var rfpworking = $('#rfpworking').DataTable({
      dom: "Bfrtip",
      destroy: true,
      ajax: {
        url: '../dependencies/datatables/php/rfpworking_table_serverside.php',
        "type": "POST",
        data: function ( d ) {
          d.val = val;
        }
      },
      serverSide: true,
      columns: [
        { data: "origin_city"},
        { data: "origin_state" },
        { data: "destination_city" },
        { data: "destination_state" },
        { data: "truck_type" },
        { data: "spot_num_companies" },
        { data: "spot_num_reports" },
        { data: "our_avg_lh" },
        { data: "our_num_reports" },
        { data: "ann_volume" },
        { data: "cust_miles" },
        { data: "market_avg_lh_dat" , render: $.fn.dataTable.render.number(',', '.', 2)},
        { data: "dat_miles" },
        { data: "avg_rpm" },
        { data: "carrier_fuel" },
        { data: "cust_fuel" },
        { data: "percent_margin" },
        { data: "margin_flat", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "cust_flat", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "cust_all_in", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "carrier_flat", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "carrier_all_in", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "all_in_gp", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "gp_percent", render: $.fn.dataTable.render.number(',', '.', 2) },
        { data: "spot_low" },
        { data: "spot_high" },
        { data: "std" },
        { data: "time" },
        { data: "hazmat" }, 
        { data: "lane_id" }, 
        { data: "extra1" }, 
        { data: "extra2" }, 
        { data: "extra3" },
        { data: "extra4" }
      ],
        autoFill: {

            editor:  editor
        },
        keys: {
  
            editor:  editor
        },
      select: {
        style:    'os',
        selector: 'td:first-child'
 
      },
      
    });
  });
};

I have added the following scripts and links

<script src="https://cdn.datatables.net/keytable/2.5.1/js/dataTables.keyTable.min.js"></script>
<script src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jqc-1.12.4/dt-1.10.20/b-1.6.1/sl-1.3.1/datatables.min.css"/>
<link rel="stylesheet" type="text/css" href="/Editor-1.9.2/css/editor.dataTables.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/keytable/2.5.1/css/keyTable.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/autofill/2.3.4/css/autoFill.dataTables.min.css">
<link rel="stylesheet" type="text/css"

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 52,498Questions: 1Answers: 8,012 Site admin
    Answer ✓

    Add:

    formOptions: {
      bubble: {
        submit: 'allIfChanged'
      }
    }
    

    to your Editor configuration (btw, remove serverSide: true from the Editor config, that's a DataTables prop - not Editor).

    AutoFill uses bubble editing to submit the form, which defaults to submit: 'changed' which is why this should address the issue you are seeing.

    Allan

  • ztaylor1990ztaylor1990 Posts: 27Questions: 10Answers: 0

    Perfect, that worked great. Thank you.

Sign In or Register to comment.