The unzipped js file does not work

The unzipped js file does not work

ChuckLuChuckLu Posts: 53Questions: 8Answers: 0

Link to test case: https://github.com/ChuckTest/DataTablesTest/commit/34aa9389dfdf9e8b4fa9279e7b71e06643eaf577
Debugger code (debug.datatables.net):
Error messages shown: DataTables warning: table id=example - Requested unknown parameter '11' for row 0, column 11. For more information about this error, please see https://datatables.net/tn/4
Description of problem:
I download the files from this link
https://datatables.net/download/#bs4/jszip-3.10.1/pdfmake-0.2.7/dt-1.13.8/af-2.6.0/b-2.4.2/b-colvis-2.4.2/b-html5-2.4.2/b-print-2.4.2/date-1.5.1/r-2.5.0
unzip it and uploaded to https://github.com/ChuckTest/DataTablesTest/tree/34aa9389dfdf9e8b4fa9279e7b71e06643eaf577/DataTables-2023-1205-001
then I reference the js file, and load the data on index.html page, got the above error

This question has accepted answers - jump to:

Answers

  • ChuckLuChuckLu Posts: 53Questions: 8Answers: 0

    also tried with cdn files , still same error

    but when I replace the js file with //cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js
    the popup error disappeared

    Could you check if there is something wrong with js files provided via https://datatables.net/download/, especially concatenated js files

  • ChuckLuChuckLu Posts: 53Questions: 8Answers: 0

    also tried another simple cdn concatenated js fiels, only bootstrap4 with datatables
    <link href="https://cdn.datatables.net/v/bs4/dt-1.13.8/datatables.min.css" rel="stylesheet">
    <script src="https://cdn.datatables.net/v/bs4/dt-1.13.8/datatables.min.js"></script>

    This version works fine, will not popup errors. But it's not the version I wanted

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    In column 11 you have this:

        {
        render: function(data, type, row) {
                                      return '<a class="btn btn-primary"  href="/UK_60_Dev_Admin/Nomination/GetNominationDetail?NominationID=' +
                                          row.TransactionID +
                                          '">View</a>';
                                  }
        }
    

    Since you are using columns.data to define the other columns try using data: null, like this:

        {
        data: null,
        render: function(data, type, row) {
                                      return '<a class="btn btn-primary"  href="/UK_60_Dev_Admin/Nomination/GetNominationDetail?NominationID=' +
                                          row.TransactionID +
                                          '">View</a>';
                                  }
        }
    

    Kevin

  • ChuckLuChuckLu Posts: 53Questions: 8Answers: 0

    Hi @kthorngren ,
    Thanks, it works with your suggestion.

    1.But why without data: null, it works fine with cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js?
    2.and without data: null, the following solution also can suppress the above error messagehttps://stackoverflow.com/questions/16539578/datatables-warning-requested-unknown-parameter-0-from-the-data-source-for-row

    oTable = $("#bigtable").dataTable({
      columnDefs: [{
        "defaultContent": "-",
        "targets": "_all"
      }]
    });
    
  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    1.But why without data: null, it works fine with cdn.datatables.net/1.13.7

    It shouldn't. If it did, it was a bug.

    Allan

  • ChuckLuChuckLu Posts: 53Questions: 8Answers: 0
    edited December 2023

    Hi @allan,
    You may check this version https://github.com/ChuckTest/DataTablesTest/tree/31f7a8b13c7a5f898dcd3ecc775fa525d78ad38e
    Reference the js and css from cdn as following:

    <link href="https://cdn.datatables.net/v/bs4/dt-1.13.8/datatables.min.css" rel="stylesheet">
    <script src="https://cdn.datatables.net/v/bs4/dt-1.13.8/datatables.min.js"></script>  
    

    Without data:null, error message should popup with you said. But there is no error message popup.(By the way, even if we have the error message popup in previous sample, the table loaded the data correctly )

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    Answer ✓

    There is nothing in that example that is asking for the raw, unrendered data. Therefore no warning is issued.

    It does happen in the first post because Responsive is being used. Responsive is requesting the unrendered data, and therefore it can't be resolved and the warning is issued.

    The upshot is, no bug, and the behaviour didn't change between versions.

    I would suggest you should always set columns.data if you are using columns.render as well. It will default to the column index, which is of no use when you have objects for the data source objects as you do here.

    Allan

  • ChuckLuChuckLu Posts: 53Questions: 8Answers: 0

    Hi @allan,
    Thanks, the issue was triggered by the responsive extension, it make senses. Suggestion is, maybe we can have different popup message, otherwise it will make user confused.

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    I think the error is actually correct - the column was configured (in its default state) to access data from array index 11. It couldn't and threw an error.

    I agree that there could be a more nuanced message, but I don't want to have loads of if conditions to guard against misconfiguration. That would increase the size of the library and only be useful during development.

    I had often wondered about doing a "debug" version of DataTables that would include such guards, and maybe one day I'll do that!

    Great to hear that it is resolved for you now though.

    Allan

  • ChuckLuChuckLu Posts: 53Questions: 8Answers: 0
    edited December 2023

    Hi @allan,
    Thanks for your patience. Yeah, from the end user side, it does not make a difference. Only the developer who is using the datatables cares about such kin of issues.

    I have filed another two issue, mostly affect the developers who used the datatables plugin
    https://datatables.net/forums/discussion/77779/popup-error-message-or-write-console-log-when-fetch-data-failed
    https://datatables.net/forums/discussion/77780/popup-error-message-or-write-console-log-when-visiblecolumns-length-does-not-match-headercells
    Both of them can improve the experience of the developer, make it easier to do the troubleshooting

Sign In or Register to comment.