s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) ) leads to Uncaught TypeError: Cannot read property parentNode of null

CS Lewis

I have a jQuery DataTable that gets loaded properly when the page loads up when you first access it. The jQuery DataTable will contain all the proper data. I am also able to successfully add a new row to the DataTable. However, when you try to make further edits to existing rows, I get the following error:

enter image description here

here is the html table code:

  <div class="row">
                            <div class="table-responsive">
                                <table id="LogEventsTable" style="overflow-x: hidden !important; overflow-y: auto !important;" class="table table-striped panel panel-info">
                                <thead>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>

Here is the LoadLogEventsTable function that gets called every time edits are made:

  var LoadLogEventsTable = function (sortColumn, isDescending, logId) {
            $('#LogEventsTable').DataTable({
                "aoColumns": [
                                 { "sTitle": "#" },
                                 { "sTitle": "LogEventValueId" },
                                 { "sTitle": "Status Code" },
                                 { "sTitle": "Start Time (24 hr clock)" },
                                 { "sTitle": "End Time (24 hr clock)" },
                                 { "sTitle": "Duration" },
                                 { "sTitle": "Latitude" },
                                 { "sTitle": "Longitude" },
                                 { "sTitle": "Location Description" },
                                 { "sTitle": "Remarks" },
                                 {
                                     // credit to http://legacy.datatables.net/usage/columns
                                 // (mData) This property can be used to read data from any JSON data source property,
                                 // including deeply nested objects / properties. mData can be given in a 
                                 // number of different ways which effect its behaviour: 
                                 // null - the sDefaultContent option will be used for the cell
                                 // (null by default, so you will need to specify the default
                                 // content you want - typically an empty string). This can be
                                 // useful on generated columns such as edit / delete action
                                 // columns.
                                 "mData": null,
                                 "mRender": function (obj) {
                                     //  var userId = obj[0].toString();
                                     // alert(obj.DT_RowId);
                                     return '<a href="#" id="' + obj.DT_RowId + '" onclick="ViewLogEventHistory(this)"  >Log Event Hist</a>';
                                     //   return '<a href="#" id="' + obj.DT_RowId + '" onclick="ViewParticularLogsInfo(this)"  >Edit</a>';
                                 }
                             },
                             {
                                 // credit to http://legacy.datatables.net/usage/columns
                                 // (mData) This property can be used to read data from any JSON data source property,
                                 // including deeply nested objects / properties. mData can be given in a 
                                 // number of different ways which effect its behaviour: 
                                 // null - the sDefaultContent option will be used for the cell
                                 // (null by default, so you will need to specify the default
                                 // content you want - typically an empty string). This can be
                                 // useful on generated columns such as edit / delete action
                                 // columns.
                                 "sTitle": "Edit",
                                 "mData": null,
                                 "mRender": function (obj) {
                                     //  var userId = obj[0].toString();
                                     // alert(obj.DT_RowId);
                                     return '<a href="#" id="' + obj.DT_RowId + '" onclick="EditLogEvent(this)"  >Edit</a>';
                                     //   return '<a href="#" id="' + obj.DT_RowId + '" onclick="ViewParticularLogsInfo(this)"  >Edit</a>';
                                 }
                             },
            ],
            "aoColumnDefs": [{ "bVisible": false, "aTargets": [1, 6, 7, 9, 10] }],
            "fnDrawCallback": function (oSettings) {

                var pgr = $(oSettings.nTableWrapper).find('.dataTables_paginate');
                var scrbdy = $(oSettings.nTableWrapper).find('.dataTables_scrollBody');

                scrbdy.css('overflow-x', 'hidden !important');
                scrbdy.css('overflow-y', 'auto !important');

                if (oSettings._iDisplayLength > oSettings.fnRecordsDisplay()) {
                    pgr.hide();
                } else {
                    pgr.show()
                }
            },
            "iDisplayLength": 10,
            "sDom": '<"clear">frtip',
            "bProcessing": true,
            "bServerSide": false,
            "bLengthChange": false,
            "bPaginate": true,
            "bDestroy": true,
            "bSort": false,
            "bInfo": true,
            "bFilter": false,
            "sAjaxSource": 'ParticularLogsDetails.aspx/BindLogEventsTable',
            "bJQueryUI": true,
            "bDeferRender": true,
            "sPaginationType": "full_numbers",
            "fnServerParams": function (aoData) {
                aoData.push(
                            { "name": "sortColumn", "value": sortColumn },
                            { "name": "isDescending", "value": isDescending },
                            { "name": "logId", "value": logId }
                );
            },
            "fnServerData": function (sSource, aoData, fnCallback) {
                $.ajax({

                    "dataType": 'json',
                    "contentType": "application/json; charset=utf-8",
                    "type": "GET",
                    "url": sSource,
                    "data": aoData,
                    "success":
                            function (msg) {
                                var obj = jQuery.parseJSON(msg.d);
                                //    alert(msg.d);
                                fnCallback(obj);

                                //if (null == $('#LogEventsTable').DataTable()) {
                                //    alert("log events table is Null");

                                //}

                                var displayDataTable = $('#LogEventsTable').DataTable();
                                // var versionNo = $.fn.dataTable.version;
                                // alert(versionNo);
                                if (obj.loggedInUserRole == 2 || obj.isFrozen == true) {
                                    displayDataTable.columns([11]).visible(false);
                                    $('#btn-AddNewEventSecondOuterDiv').css('display', 'none');
                                    $('#btn-AddNewEventOuterDiv').css('display', 'none');
                                    $('#btn-AddNewEvent').css('display', 'none');
                                    $('#btn-LogEditSecondOuterDiv').css('display', 'none');
                                    $('#btn-LogEditOuterDiv').css('display', 'none');
                                    $('#btn-LogEdit').css('display', 'none');
                                } // end if (obj.loggedInUserRole == 2) 


                            },

                    beforeSend: function () {
                        $('.loader').show()
                    },
                    complete: function () {
                        $('.loader').hide()

                    }
                });
            }
        })
    } 

Could someone please tell me how the aforementioned error can be resolved?

CS Lewis

All:

I believe the problem was that with jQuery DataTables, it is important that you populate the HTML declaration with tag, and it's corresponding header title rows like the following even though we might be programmatically specifying the Header title rows in the JavaScript:

                        <table id="aTable" class="table
table-striped">
                            <thead>
                                <tr>
                                    <th>Vehicle Reg. No.</th>
                                    <th>Date</th>
                                    <th>Driver Name</th>
                                    <th>Total Defects </th>
                                    <th>Open Defects</th>
                                    <th>Status</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Merging Users in Kinvey

From Dev

PostgreSQL: Efficiently split JSON array into rows

From Dev

boost::asio how to read full buffer in right way?

From Dev

GIT SVN: fetching a recreated SVN branch without the wrong merge parent

From Dev

How to find out value of a particular attribute index in core data model iOS

From Dev

iOS - iPad preview in Xcode is missing

From Dev

Java: Method hooking & Finding object instances

From Dev

Using git diff, how can I show the patch from the index to a given commit?

From Dev

Cast for upcasting only

From Dev

How can I multiply or divide value under the cursor by a repeat count?

From Dev

Can`t compile boost spirit word_count_lexer example

From Java

How to make a for loop variable const with the exception of the increment statement?

From Java

Count letters in a text in the Welsh language

From Java

Why does using the ternary operator to return a string generate considerably different code from returning in an equivalent if/else block?

From Java

No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase

From Java

Changes using mutable reference of a field are not reflected after move of the original instance

From Java

Elastic Search indexes gets deleted frequently

From Java

Forgot do in do... while loop

From Java

How to fix "An unexpected error occurred. Please try again later. (7100000)" error in Google Play Console?

From Java

Does C# perform short circuit evaluation of if statements with await?

From Java

Why doesn't Python give any error when quotes around a string do not match?

From Java

Why is this regular expression so slow in Java?

From Java

Why are my two tuples containing strings, created the same way, not equal?

From Java

How to pass array initialization thru custom structure?

From Java

Why does Python code run faster in a function?

From Java

How to set same alignment for these two text

From Java

How to wrap title on to new line react native

From Dev

Run grunt task asynchronously before another task

From Dev

Bootstrap 3: Scroll bars

Related Related

  1. 1

    Merging Users in Kinvey

  2. 2

    PostgreSQL: Efficiently split JSON array into rows

  3. 3

    boost::asio how to read full buffer in right way?

  4. 4

    GIT SVN: fetching a recreated SVN branch without the wrong merge parent

  5. 5

    How to find out value of a particular attribute index in core data model iOS

  6. 6

    iOS - iPad preview in Xcode is missing

  7. 7

    Java: Method hooking & Finding object instances

  8. 8

    Using git diff, how can I show the patch from the index to a given commit?

  9. 9

    Cast for upcasting only

  10. 10

    How can I multiply or divide value under the cursor by a repeat count?

  11. 11

    Can`t compile boost spirit word_count_lexer example

  12. 12

    How to make a for loop variable const with the exception of the increment statement?

  13. 13

    Count letters in a text in the Welsh language

  14. 14

    Why does using the ternary operator to return a string generate considerably different code from returning in an equivalent if/else block?

  15. 15

    No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase

  16. 16

    Changes using mutable reference of a field are not reflected after move of the original instance

  17. 17

    Elastic Search indexes gets deleted frequently

  18. 18

    Forgot do in do... while loop

  19. 19

    How to fix "An unexpected error occurred. Please try again later. (7100000)" error in Google Play Console?

  20. 20

    Does C# perform short circuit evaluation of if statements with await?

  21. 21

    Why doesn't Python give any error when quotes around a string do not match?

  22. 22

    Why is this regular expression so slow in Java?

  23. 23

    Why are my two tuples containing strings, created the same way, not equal?

  24. 24

    How to pass array initialization thru custom structure?

  25. 25

    Why does Python code run faster in a function?

  26. 26

    How to set same alignment for these two text

  27. 27

    How to wrap title on to new line react native

  28. 28

    Run grunt task asynchronously before another task

  29. 29

    Bootstrap 3: Scroll bars

HotTag

Archive