Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82709

Default Value in Editor

$
0
0

I need to have the ID from table 1 as a default value for the editor field that will save into table 2. This is what I have but it is not working.

  $(document).ready(function() {
        var editor = new $.fn.dataTable.Editor({
            ajax: 'php/table.query.php',
            table: '#sku_request',
            fields: [{
                    label: "Note:",
                    name: "dpe_notes.note"
                },

                {
                    label: "Your Name:",
                    name: "dpe_notes.user"
                },
                {
                label: "Note ID:",
                name: "dpe_notes.note_id",
                def: function (data, type, full, meta, row) { return data.ID; }
            },




            ]
        });

The Note ID is what I need as the default from the table. The note ID is the ID from table 1.

My full script

(function($) {

    $(document).ready(function() {
        var editor = new $.fn.dataTable.Editor({
            ajax: 'php/table.sku_request.php',
            table: '#sku_request',
            fields: [{
                    label: "Note:",
                    name: "dpe_notes.note"
                },

                {
                    label: "Your Name:",
                    name: "dpe_notes.user"
                },
                {
                label: "Note ID:",
                name: "dpe_notes.note_id",
                def: function (data, type, full, meta, row) { return full.dp_expected.note_id; }
            },




            ]
        });

    $(document).ready( function () {
  var table = $('#sku_request').DataTable({
        ajax: 'php/table.sku_request.php',
        dom: 'Bfrtip',
        select: true,
        pageLength: 10,
        lengthChange: true,
        scrollX: true,

        language: {
                searchPanes: {
                        clearMessage: 'Clear All',
                        collapse: 'Filter',
                        cascadePanes: true,
                        viewTotal: true,
                        layout: 'columns-2',
                        dataLength: true

                }
        },
        buttons: [
                {
                        extend: "remove",
                        text: "Delete",
                        editor: editor
                },

                {
                        extend: "excelHtml5",
                        text: "Excel"
                },
        {
            extend: "edit",
            text: "Update",
            editor: editor
        },


        ],


        columns: [

      {
          data: "dp_expected.ID"
      },
      {
          data: "dp_expected.Invoice_"
      },
      {
          data: "dp_expected.District"
      },
      {
          data: "dp_expected.Sold_By"
      },
      {
        data: null,
        render: function ( data, type, full, meta, row ) {
                // Combine the first and last names into a single table field
              if(full.dpe_notes.note >= 0){
                return 'No Notes';
              }else {

                  return full.dpe_notes.note+' - '+full.dpe_notes.user;
              }

            } },
        ],
  });
} );


    });

}(jQuery));

Viewing all articles
Browse latest Browse all 82709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>