Passing Primary Key ID in URL to new page

Passing Primary Key ID in URL to new page

kdavid@kremzeeks.comkdavid@kremzeeks.com Posts: 4Questions: 3Answers: 0

Hello,

I love Datatables and plan to purchase the Editor once the trial expires. With that said, I am relatively new to JQuery and am banging my head attempting to figure out one thing. I am using inline editing but need to allow the user to click an icon on each row of the last column. That should append the primary key of the row to the URL ($_GET['ID']) and send it via Ajax to the #example table. My issue is that I keep getting "uncaught exception: Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11".

I know what is going on and tried everything to get this to go away. Is there an example somewhere that shows how to do this? Any help would be greatly appreciated. I've attached the code below:

<html>
    <head>
        <script type="text/javascript" language="javascript" class="init">
            var editor; // use a global for the submit and return data rendering in the examples

            $(document).ready(function() 
                {
                    editor = new $.fn.dataTable.Editor
                    ( 
                        {
                            ajax: "Forms_Site_Information/index_TESTING2.php",
                            table: "#example",
                            fields: 
                            [ 
                                {
                                    label: "Form name:",
                                    name: "CTG_TRACKING_FORM_NAME"
                                }, 
                                {
                                    label: "Protocol:",
                                    name: "CTG_TRACKING_FORM_PROTOCOL"
                                }, 
                                {
                                    label: "Site #:",
                                    name: "CTG_TRACKING_FORM_SITE"
                                }, 
                                {
                                    label: "PI:",
                                    name: "CTG_TRACKING_FORM_PI"
                                }, 
                                {
                                    label: "Active:",
                                    name: "CTG_TRACKING_FORM_ACTIVE"
                                }
                            ]
                        } 
                    ); // (END) editor = new $.fn.dataTable.Editor







                    editor.on( 'preSubmit', function ( e, o, action ) 
                        {
                            if ( action !== 'remove' ) {
                                var daCTG_TRACKING_FORM_NAME = editor.field( 'CTG_TRACKING_FORM_NAME' );
                     
                                // Only validate user input values - different values indicate that
                                // the end user has not entered a value
                                if ( ! daCTG_TRACKING_FORM_NAME.isMultiValue() ) {
                                    if ( ! daCTG_TRACKING_FORM_NAME.val() ) {
                                        daCTG_TRACKING_FORM_NAME.error( 'A first name must be given' );
                                    }
                                     
                                    if ( (daCTG_TRACKING_FORM_NAME.val().length < 5) && (daCTG_TRACKING_FORM_NAME.val().length > 15) ) {
                                        daCTG_TRACKING_FORM_NAME.error( 'The first name length must be less that 20 characters' );
                                    }
                                }
                     
                                // ... additional validation rules
                     
                                // If any error was reported, cancel the submission so it can be corrected
                                if ( this.inError() ) {
                                    return false;
                                }
                            }
                        } 
                    ); // (END) editor.on( 'preSubmit', function ( e, o, action )



                    
                    
                    
                    
                    

                    // Activate an inline edit on click of a table cell
                    $('#example').on( 
                        'click', 
                        'tbody td:not(:first-child)', 
                        function (e) 
                            {
                                editor.inline( this );
                            } 
                    ); // (END) $('#example').on(






                    
                    var table = $('#example').DataTable( 
                        {
                            dom: "Bfrtip",
                            ajax: "Forms_Site_Information/index_TESTING2.php",
                            columns: 
                                [
                                    {
                                        data: null,
                                        defaultContent: '',
                                        className: 'select-checkbox',
                                        orderable: false
                                    },
                                    { data: "CTG_TRACKING_FORM_NAME" },
                                    { data: "CTG_TRACKING_FORM_PROTOCOL" },
                                    { data: "CTG_TRACKING_FORM_SITE" },
                                    { data: "CTG_TRACKING_FORM_PI" },
                                    { data: "CTG_TRACKING_FORM_ACTIVE" },
                                    {
                                        data: null,
                                        ajax: "Forms_Site_Information/index_TESTING3.php?ID=what_do_I_put_here_for_the_Primary_Key_ID_for_this_row",
                                        className: "center",
                                        defaultContent: '<i class="fa fa-map"></i>'
                                    }
                                ], // (END) columns:
                            order: [ 1, 'asc' ],
    
                    ); // (END) var table = $('#example').DataTable( 
                    table.on
                        (   'key-focus', 
                            function ( e, datatable, cell ) 
                                {
                                    editor.inline( cell.index(), 
                                        {
                                            onBlur: 'submit'
                                        } 
                                    );
                                } 
                        ); // (END) table.on
                }
            ); // (END) $(document).ready(function()
        </script>
    </head>
    <body class="dt-example dt-example-jqueryui">
        <div class="container">
            <form id="form1" method="post" action="">
                <div class="daBreadcrumbs" id='daBC'>
                    Dashboard > Form #: 1 > Site Information (Export)</i>
                </div>
                <p></p>
                <fieldset>  
                    <table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th id="daDataTableHeader"></th>
                                <th id="daDataTableHeader">Form Name</th>
                                <th id="daDataTableHeader">Protocol</th>
                                <th id="daDataTableHeader">Site #</th>
                                <th id="daDataTableHeader">PI</th>
                                <th id="daDataTableHeader"  width="8">Active</th>
                                <th id="daDataTableHeader"></th>
                                
                            </tr>
                        </thead>
                    </table>
                </fieldset>
            </form>
        </div>
    </body>
</html>

This discussion has been closed.