datatables error when adding type Upload, suggestions?

datatables error when adding type Upload, suggestions?

Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

Hi, first sorry for never coming to you all with easy problems.

I am having the the weirdest problem with trying to use the file upload function.

When I add the type and it's parameters I get the following error

dataTables.editor.min.js:6 Uncaught Error: Unknown file table name: files
    at R.Ft [as files] (dataTables.editor.min.js:6:23010)
    at R.kt [as file] (dataTables.editor.min.js:6:22855)
    at render (correspondence.php:619:49)
    at jquery.dataTables.min.js:4:12048
    at e.fnGetData (jquery.dataTables.min.js:4:15343)
    at S (jquery.dataTables.min.js:4:17860)
    at St (jquery.dataTables.min.js:4:20342)
    at x (jquery.dataTables.min.js:4:17588)
    at jquery.dataTables.min.js:4:32832
    at Object.e [as success] (jquery.dataTables.min.js:4:25688)

But this error only occurs with the type field, otherwise it works fine. Here's the Libraries, and Script. When I remove the remarks, it fails. I can run the same script independently, and it works.

libload.html:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script src="https://kit.fontawesome.com/d30fa74399.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.2/moment.min.js"></script>
<script src="https://cdn.datatables.net/1.13.2/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.2/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/select/1.6.0/js/dataTables.select.min.js"></script>
<script src="https://cdn.datatables.net/datetime/1.3.0/js/dataTables.dateTime.min.js"></script>
<script src="Editor-PHP-2.1.0/js/dataTables.editor.min.js"></script>
<script src="Editor-PHP-2.1.0/js/editor.bootstrap5.min.js"></script>                                
<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.9.0/js/standalone/selectize.js"></script>                                
<script src="Editor-PHP-2.1.0/js/editor.selectize.js"></script>  
<script src="https://cdn.quilljs.com/latest/quill.min.js"></script>                                        

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.13.2/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/buttons/2.3.4/css/buttons.bootstrap5.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/select/1.6.0/css/select.bootstrap5.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/datetime/1.3.0/css/dataTables.dateTime.min.css" rel="stylesheet" />
<link href="Editor-PHP-2.1.0/css/editor.bootstrap5.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.9.0/css/selectize.css" rel="stylesheet" />
<link href="Editor-PHP-2.1.0/css/editor.selectize.css" rel="stylesheet" />
<link href="https://cdn.quilljs.com/latest/quill.snow.css" rel="stylesheet" />

ajaxCorrespondence.php

<?php
session_start();
include( "Editor-PHP-2.1.0/lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;


/*
 * Example PHP implementation used for the join.html example
 */

    Editor::inst( $db, 'Correspondence' )
    ->fields(
        Field::inst( 'CR_ID' ),
        Field::inst( 'Notes' ),
        Field::inst( 'image' )                
    //     ->setFormatter( Format::ifEmpty( null ) )
    //     ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/uploads/__ID__.__EXTN__' )
    //         ->db( 'files', 'id', array(
    //             'filename'    => Upload::DB_FILE_NAME,
    //             'filesize'    => Upload::DB_FILE_SIZE,
    //             'web_path'    => Upload::DB_WEB_PATH,
    //             'system_path' => Upload::DB_SYSTEM_PATH
    //         ) )
    //         ->validator( Validate::fileSize( 500000, 'Files must be smaller that 500K' ) )
    //         ->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif' ), "Please upload an letter" ) )
    //         )

    )
    ->process( $_POST )
    ->json();

scanners.html

<script>
    var editor; // use a global for the submit and return data rendering in the examples
     
    $(document).ready(function() { 
        editor = new $.fn.dataTable.Editor( {
            ajax: "ajaxCorrespondence.php",
            table: "#correspondenceTable",
            display: 'bootstrap',      
            fields: [ {
                    label: "Contact ID:",
                    name:  "CR_ID"
                }, {
                    label: "Notes:",
                    name:  "Notes"
                }, {                    
                    label: "Scanned Letter:",
                    name: "image"
                    // type: "upload",
                    // display: function ( file_id ) {
                    //        return '<img src="'+editor.file( 'files', file_id ).web_path+'"/>';
                    // },
                    // clearText: "Clear",
                    // noImageText: 'No Scan'

                }
            ]

        } );

        editor.on('open', function(e, mode, action) {
            $('div.modal-dialog', editor.displayNode()).addClass('modal-xl');
 
        });    

        var table = $('#correspondenceTable').DataTable( {
            lengthChange: false,
            ajax: "ajaxCorrespondence.php",
            columns: [
                {data: "CR_ID" },
                {data: "Notes" },
                {
                    data: "image"
                    // render: function ( file_id ) {
                    //     return file_id ?
                    //         '<img src="'+editor.file( 'files', file_id ).web_path+'" width="45" height="45"/>' :
                    //         null;
                    // },
                    // defaultContent: "No scan",
                    // title: "Letter"
                }                
            ],
            select: true
        } );

        // Display the buttons
        new $.fn.dataTable.Buttons( table, [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ] );
    
        table.buttons().container()
            .appendTo( $('.col-md-6:eq(0)', table.table().container() ) );
    } );
    </script>

    <table id="correspondenceTable" class="table table-striped" style="width:100%">
        <thead>
            <tr>
                <th>CR_ID</th>
                <th>Notes</th>
                <th>image</th>        
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>CR_ID</th>
                <th>Notes</th>
                <th>image</th>
            </tr>
        </tfoot>
    </table> 

I had more code, but it exceeded the posting limits.

I am at a loss, and my forehead is bruised from banging it against the wall for the past few days. Any insights and suggestions would be really helpful right now. The scanner.html file will actually have more fields, with selects, and joins. But I already have them working okay in other modules.

Thanks...... Oh, before I forget, the following code does not work in 2.1.0, is there a new work around?

        editor.on('open', function(e, mode, action) {
            $('div.modal-dialog', editor.displayNode()).addClass('modal-xl');
 
        });   

Thanks so much!

This question has accepted answers - jump to:

Answers

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0
    edited March 2023

    So I got it to work with your users and files table. I need it to work with my tables, but I am getting the above error when using my tables.

    If I use any table named other than users, it errors our.

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0
    edited March 2023

    Nevermind. With a rested brain, I copied the users and files tables from my examples, and they work. Don't know what the difference is but since this is a new module it doesn't matter.

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    Hi,

    Thanks for the update - good to hear you've got it working now. If if gives you problems again in future, just post back then.

    Allan

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

    So, I'm posting back ... The problem now is I am linking two tables from different databases using dbname.tablename.fieldname convention. It works the link and everything works fine. However the upload function seems not be able to recognize it.

    relevant php code:

            Field::inst( 'abo.Contributors.image' )                
                ->setFormatter( Format::ifEmpty( null ) )
                ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/uploads/__ID__.__EXTN__' )
                    ->db( 'abo.scanned_files', 'id', array(
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        'web_path'    => Upload::DB_WEB_PATH,
                        'system_path' => Upload::DB_SYSTEM_PATH
                    ) )
                    ->validator( Validate::fileSize( 500000, 'Files must be smaller that 500K' ) )
                    ->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif' ), "Please upload an image" ) )
                ),
            Field::inst( 'abo.Contributors.hasWaiver' )
                ->searchBuilderOptions( SearchBuilderOptions::inst()), 
    

    relevant js code:

                    }, {
                        label: "Contributor's Bio:",
                        name:  "abo.Contributors.Bio",
                        type:  "quill"
                    }, {                
                                   
                        label: "Contributor's Photo :",
                        name: "abo.Contributors.image",
                        type: "upload",
                        display: function ( file_id ) {
                            return '<img src="'+editor.file( 'abo.scanned_files', file_id ).web_path+'"/>';
                        },
                        clearText: "Clear",
                        noImageText: 'No image'
                    }, {
                        label: "Release/Waiver on File:",
                        name:  "abo.Contributors.hasWaiver",
                        type:  "radio",
                        options: [
                            { label: "No", value: 0},
                            { label: "Yes", value: 1}
                        ],
                        def: 0
                    }, {
    

    error code:

    dataTables.editor.min.js:6 Uncaught Error: Unknown file table name: abo.scanned_files
        at R.Ft [as files] (dataTables.editor.min.js:6:23102)
        at R.kt [as file] (dataTables.editor.min.js:6:22947)
        at Object.display (contributors.php:240:52)
        at R.set (dataTables.editor.min.js:6:53980)
        at O._typeFn (dataTables.editor.min.js:6:64086)
        at O.set (dataTables.editor.min.js:6:61987)
        at O._multiValueCheck (dataTables.editor.min.js:6:63677)
        at O.<anonymous> (dataTables.editor.min.js:6:34721)
        at Function.each (jquery-3.6.0.min.js:2:3053)
        at R.be [as _edit] (dataTables.editor.min.js:6:34328)
    

    I am not joining the scanned_files table witht the Contributors table if that makes a difference. Thanks in advance.

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    Can you show me the JSON response from the server for when the data is loaded for the table please?

    Allan

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    Sorry, can you give me the full, raw JSON of the response please? There is a lot of truncated information there.

    Allan

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

    Sorry, I created it in a text file, and it is huge (nearly a MB) and sensitive. I tried sanitize the first 5 records, and grab the bottom, but there is so much join data I can't make heads or tails of it. I guess I could do this without datatables....but kinda defeats the purpose. Wednesday, I could try to put a where clause and insert 5 test records, the file will still be too huge to post directly however.

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    I'm actually not that bothered about what is in the data parameter for this JSON return (i.e. the data for the rows). It is the files object that I would need to see. Based on the error, I presume that there is no abo.scanned_files property in it, but I don't know for certain if that is the issue or not (hence the back and forth needing more debugging information - sorry!).

    Allan

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

    here I took the first record, and the and the rest is just links, based on what you posted I believe this will help?

    {"data":
        [{"DT_RowId":"row_10001","abo":
            {"Contributors":
                {"id":"10001",
                    "FullName":"XXXXXXXXXXXXXXXXXXXXXXXXXX",
                    "LastName":"XXXXXXXXXX",
                    "FirstName":"XXXXXXXXX",
                    "PreferredName":"XXXXXXXXXXX",
                    "PrisonID":"XXXXXXX",
                    "FacilityID":"0",
                    "PrisonUnit":"McPherson Unit",
                    "Address":"302 Corrections Dr.",
                    "City":"Newport",
                    "State":"AR",
                    "Zipcode":"72112",
                    "MailingNotes":"",
                    "Birthday":"XXXXXXXXXX",
                    "Age":"XX",
                    "Race_Ethnicity":"XXXXXXX",
                    "Sexual_Orientation":"XXXXXXXXXXX",
                    "Gender_Identity":"Female",
                    "Disability":"No",
                    "Donations":"Deposited directly to commissary\/trust fund.",
                    "Bio":"Bio.jpg (https:\/\/airtable.com\/appaoeR70RJjOsJzq\/tbl5nnDnhZT70soQw\/recfFmNTz7IgxEI1g\/fldmf0NxE1ELeAg6I\/attO3ruvHqSVSwCEb)",
                    "image":"0",
                    "hasWaiver":"0",
                    "isSubscribed":"1",
                    "noGCards":"0",
                    "firstContact":"0000-00-00",
                    "EditedBy":"xxxxxxxxx@gmail.com"
                }
            },"croak":
            {"PrisonFacilityListing":
                {"Prison_Name":null,
                    "publications":null,
                    "Address_1":null,
                    "Address_2":null,
                    "Address_3":null,
                    "City":null,
                    "State":null,
                    "Zipcode":null,
                    "Mail_Addr_1":null,
                    "Mail_Addr_2":null,
                    "Mail_Addr_3":null,
                    "Mail_City":null,
                    "Mail_State":null,
                    "Mail_Zip":null,
                    "Pkg_Addr_1":null
                    ,"Pkg_Addr_2":null,
                    "Pkg_Addr_3":null,
                    "Pkg_City":null,
                    "Pkg_State":null,
                    "Pkg_Zip":null,
                    "Alt_Addr_1":null,
                    "Alt_Addr_2":null,
                    "Alt_Addr_3":null,
                    "Alt_City":null,
                    "Alt_State":null,
                    "Alt_Zip":null
                }
            }
        }],"options":
            {"abo.Contributors.FacilityID":
                [{"label":" ASPC - PERRYVILLE PIESTEWA UNIT ",
                "value":"1006098"}, 
                {"label":" Butler County Juvenile Detention & Rehabilitation Center",
                "value":"1007101"},
                {"label":" Butts County Detention Center",
                "value":"1001050"} 
                ...
                ]   
            }
        ...
    }       
    

    Thanks for you assistance. Like I said before, the editor works fine without the reference to the image file.

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    There should be a files property for the JSON that is return from the server. You've shown the data and options properties above (thanks for that), but if you could also show me the files property, that is what I'm currently after.

    Thanks,
    Allan

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

    okay, I found only one(1) instance in the whole return

          ...  ,
            {"label":"[CLOSED] Gloucester County Juvenile Detention","value":"1003831"},
            {"label":"[CLOSED] Hunterdon County Jail ","value":"1003846"},
            {"label":"[CLOSED] Passaic County Youth Detention Center","value":"1003854"},
            {"label":"\u00c9tablissement de Port-Cartier","value":"1006931"}
        ]},
        "files":[],"searchBuilder":
            {"options":
                {"abo.Contributors.LastName":
                    [{"value":"Aguirre","label":"Aguirre"},
                    {"value":"Ahrens","label":"Ahrens"}, 
          ...
    
    
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    edited June 2023 Answer ✓

    Thanks.

    That explains why you are getting the error Unknown file table name: files from the original post then. If you are going to use the file() API method to display information about a file, then you need to prime the JSON with that information.

    That should be getting done by the Upload method. That it isn't suggests that there are no files in recorded in the database (or that there is an error somewhere!).

    Consider this example. If you upload a file then reload the page, you'll be able to see that the JSON returns information about the file - e.g.:

      "files": {
        "files": {
          "1": {
            "id": "1",
            "filename": "2023-02-12_18-09.png",
            "filesize": "23877",
            "web_path": "/uploads/1.png",
            "system_path": "/home/datat/public_html/editor/uploads/1.png"
          }
        }
      }
    

    So the question becomes - why is the PHP on your server not including that sort of information.

    A step towards answering that would be to enable debug mode - which you do by adding ->debug(true) immediately before the ->process(...) method call. Then in the JSON return the SQL that is generated and executed will be shown. Can you show me the debug property from the JSON abbreviated please?

    Thanks,
    Allan

  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

    Sorry for the delay, here it is (and now I know what that debug true line does).

    "debug":["Editor PHP libraries - version 2.1.3",{"query":"SELECT `abo`.`Contributors`.`id` as 'abo.Contributors.id', `abo`.`Contributors`.`FullName` as 'abo.Contributors.FullName', `abo`.`Contributors`.`LastName` as 'abo.Contributors.LastName', `abo`.`Contributors`.`FirstName` as 'abo.Contributors.FirstName', `abo`.`Contributors`.`PreferredName` as 'abo.Contributors.PreferredName', `abo`.`Contributors`.`PrisonID` as 'abo.Contributors.PrisonID', `abo`.`Contributors`.`FacilityID` as 'abo.Contributors.FacilityID', `croak`.`PrisonFacilityListing`.`Prison_Name` as 'croak.PrisonFacilityListing.Prison_Name', `croak`.`PrisonFacilityListing`.`publications` as 'croak.PrisonFacilityListing.publications', `croak`.`PrisonFacilityListing`.`Address_1` as 'croak.PrisonFacilityListing.Address_1', `croak`.`PrisonFacilityListing`.`Address_2` as 'croak.PrisonFacilityListing.Address_2', `croak`.`PrisonFacilityListing`.`Address_3` as 'croak.PrisonFacilityListing.Address_3', `croak`.`PrisonFacilityListing`.`City` as 'croak.PrisonFacilityListing.City', `croak`.`PrisonFacilityListing`.`State` as 'croak.PrisonFacilityListing.State', `croak`.`PrisonFacilityListing`.`Zipcode` as 'croak.PrisonFacilityListing.Zipcode', `croak`.`PrisonFacilityListing`.`Mail_Addr_1` as 'croak.PrisonFacilityListing.Mail_Addr_1', `croak`.`PrisonFacilityListing`.`Mail_Addr_2` as 'croak.PrisonFacilityListing.Mail_Addr_2', `croak`.`PrisonFacilityListing`.`Mail_Addr_3` as 'croak.PrisonFacilityListing.Mail_Addr_3', `croak`.`PrisonFacilityListing`.`Mail_City` as 'croak.PrisonFacilityListing.Mail_City', `croak`.`PrisonFacilityListing`.`Mail_State` as 'croak.PrisonFacilityListing.Mail_State', `croak`.`PrisonFacilityListing`.`Mail_Zip` as 'croak.PrisonFacilityListing.Mail_Zip', `croak`.`PrisonFacilityListing`.`Pkg_Addr_1` as 'croak.PrisonFacilityListing.Pkg_Addr_1', `croak`.`PrisonFacilityListing`.`Pkg_Addr_2` as 'croak.PrisonFacilityListing.Pkg_Addr_2', `croak`.`PrisonFacilityListing`.`Pkg_Addr_3` as 'croak.PrisonFacilityListing.Pkg_Addr_3', `croak`.`PrisonFacilityListing`.`Pkg_City` as 'croak.PrisonFacilityListing.Pkg_City', `croak`.`PrisonFacilityListing`.`Pkg_State` as 'croak.PrisonFacilityListing.Pkg_State', `croak`.`PrisonFacilityListing`.`Pkg_Zip` as 'croak.PrisonFacilityListing.Pkg_Zip', `croak`.`PrisonFacilityListing`.`Alt_Addr_1` as 'croak.PrisonFacilityListing.Alt_Addr_1', `croak`.`PrisonFacilityListing`.`Alt_Addr_2` as 'croak.PrisonFacilityListing.Alt_Addr_2', `croak`.`PrisonFacilityListing`.`Alt_Addr_3` as 'croak.PrisonFacilityListing.Alt_Addr_3', `croak`.`PrisonFacilityListing`.`Alt_City` as 'croak.PrisonFacilityListing.Alt_City', `croak`.`PrisonFacilityListing`.`Alt_State` as 'croak.PrisonFacilityListing.Alt_State', `croak`.`PrisonFacilityListing`.`Alt_Zip` as 'croak.PrisonFacilityListing.Alt_Zip', `abo`.`Contributors`.`PrisonUnit` as 'abo.Contributors.PrisonUnit', `abo`.`Contributors`.`Address` as 'abo.Contributors.Address', `abo`.`Contributors`.`City` as 'abo.Contributors.City', `abo`.`Contributors`.`State` as 'abo.Contributors.State', `abo`.`Contributors`.`Zipcode` as 'abo.Contributors.Zipcode', `abo`.`Contributors`.`MailingNotes` as 'abo.Contributors.MailingNotes', `abo`.`Contributors`.`Birthday` as 'abo.Contributors.Birthday', `abo`.`Contributors`.`Age` as 'abo.Contributors.Age', `abo`.`Contributors`.`Race_Ethnicity` as 'abo.Contributors.Race_Ethnicity', `abo`.`Contributors`.`Sexual_Orientation` as 'abo.Contributors.Sexual_Orientation', `abo`.`Contributors`.`Gender_Identity` as 'abo.Contributors.Gender_Identity', `abo`.`Contributors`.`Disability` as 'abo.Contributors.Disability', `abo`.`Contributors`.`Donations` as 'abo.Contributors.Donations', `abo`.`Contributors`.`Bio` as 'abo.Contributors.Bio', `abo`.`Contributors`.`image` as 'abo.Contributors.image', `abo`.`Contributors`.`hasWaiver` as 'abo.Contributors.hasWaiver', `abo`.`Contributors`.`isSubscribed` as 'abo.Contributors.isSubscribed', `abo`.`Contributors`.`noGCards` as 'abo.Contributors.noGCards', `abo`.`Contributors`.`firstContact` as 'abo.Contributors.firstContact', `abo`.`Contributors`.`EditedBy` as 'abo.Contributors.EditedBy' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` LIMIT 5","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`LastName` as 'value', `abo`.`Contributors`.`LastName` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`LastName`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`FirstName` as 'value', `abo`.`Contributors`.`FirstName` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`FirstName`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`PrisonID` as 'value', `abo`.`Contributors`.`PrisonID` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`PrisonID`","bindings":[]},{"query":"SELECT DISTINCT `Facility_ID` as 'Facility_ID', `Prison_Name` as 'Prison_Name' FROM `croak`.`PrisonFacilityListing` ","bindings":[]},{"query":"SELECT `croak`.`PrisonFacilityListing`.`Prison_Name` as 'value', `croak`.`PrisonFacilityListing`.`Prison_Name` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `croak`.`PrisonFacilityListing`.`Prison_Name`","bindings":[]},{"query":"SELECT `croak`.`PrisonFacilityListing`.`State` as 'value', `croak`.`PrisonFacilityListing`.`State` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `croak`.`PrisonFacilityListing`.`State`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`PrisonUnit` as 'value', `abo`.`Contributors`.`PrisonUnit` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`PrisonUnit`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`Birthday` as 'value', `abo`.`Contributors`.`Birthday` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`Birthday`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`Race_Ethnicity` as 'value', `abo`.`Contributors`.`Race_Ethnicity` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`Race_Ethnicity`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`Sexual_Orientation` as 'value', `abo`.`Contributors`.`Sexual_Orientation` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`Sexual_Orientation`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`Gender_Identity` as 'value', `abo`.`Contributors`.`Gender_Identity` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`Gender_Identity`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`Disability` as 'value', `abo`.`Contributors`.`Disability` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`Disability`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`hasWaiver` as 'value', `abo`.`Contributors`.`hasWaiver` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`hasWaiver`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`isSubscribed` as 'value', `abo`.`Contributors`.`isSubscribed` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`isSubscribed`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`noGCards` as 'value', `abo`.`Contributors`.`noGCards` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`noGCards`","bindings":[]},{"query":"SELECT `abo`.`Contributors`.`firstContact` as 'value', `abo`.`Contributors`.`firstContact` as 'label' FROM `abo`.`Contributors` LEFT JOIN `croak`.`PrisonFacilityListing` ON `croak`.`PrisonFacilityListing`.`Facility_ID` = `abo`.`Contributors`.`FacilityID` GROUP BY `abo`.`Contributors`.`firstContact`","bindings":[]}]}
    
  • Stacey1134Stacey1134 Posts: 112Questions: 20Answers: 0

    Yay!, fixed it. Using what you mentioned in your last post and adding this:

    table.on( 'xhr', function () {
                var json = table.ajax.json();
                console.log( JSON.stringify(json.data, null, 3));
            } );
    

    I was able to cleanly look at the ajax response and I noticed that the every image record had '0' instead of 'null'. Of course there is no '0' in the files table. I reset the column in all the rows to null, and the table loaded correctly.

    What concerns me, however, is that if the the datatable fails to load because it didn't see a the file identifier, will it fail if the file is removed from the the file table? Could be problematic.

    Thanks for helping with this, and giving me good feedback to find the problem

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Nice one!

    What concerns me, however, is that if the the datatable fails to load because it didn't see a the file identifier, will it fail if the file is removed from the the file table?

    Why would it try to reference a file that has been deleted though? The link to the file should use a foreign key - so you can't delete the file without deleting the reference to it. If that were possibly, then as you say, that would be a problem, and you'd need a try / catch when you call the file() method if that is something you expect might happen.

    Allan

Sign In or Register to comment.