ASP.NET Dynamic Data Website: Microsoft JScript runtime error

ASP.NET Dynamic Data Website: Microsoft JScript runtime error

MIT560MIT560 Posts: 4Questions: 0Answers: 0
edited August 2011 in DataTables 1.8
Hello,
Has anyone else run into the following error?

[quote]Microsoft JScript runtime error: Unable to get value of the property 'asSorting': object is null or undefined[/quote]

I am using ASP.NET's Dynamic Data templates and this error is being thrown from the DataTables plugin at line 7272. It seems to only happen if the table is null.

Here is the JavaScript I am using to initialize the plugin on the table. Also of note the jQuery button statement is not being applied as well. They both work on pages that have records returned.
[code]
$(document).ready(function () {
var oTable = $("div.AspNet-GridView table").dataTable({
"bJQueryUI": true,
"bFilter": true,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"sPaginationType": "full_numbers"
}).fnFilterOnReturn();

$(".button-insert").button({
icons: {
primary: "ui-icon-plusthick"
}
});

});
[/code]

Here is the rendered html that is displaying for the table.
[code]





[/code]

Could this be due to the fact that the table is rendering without any TH tags and the script is looking for some to apply the sorting methods to?
Thanks for your help in advance.
Regards,
MIT560

Replies

  • MIT560MIT560 Posts: 4Questions: 0Answers: 0
    Came up with an idea for a work around. Instead of letting the dataTable JavaScript run on all page loads, I made a function that would check the number of rows in the table and if there is 0 records then bypass the script. So this is now the code I am using.

    [code]
    $(document).ready(function () {

    intTable();

    })

    function intTable() {
    var rowCount = $('div.AspNet-GridView table tr').length;
    if (rowCount != 0) {
    var oTable = $("div.AspNet-GridView table").dataTable({
    "bJQueryUI": true,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "bAutoWidth": false,
    "sPaginationType": "full_numbers"
    }).fnFilterOnReturn();
    };
    }
    [/code]

    Due to Dynamic Data's nature I cannot create a table with headers easily so I chose to fix it this way. If there is a better way feel free to post it here or at http://www.mit560.com/2011/08/19/206

    Regards,
    MIT560
  • MIT560MIT560 Posts: 4Questions: 0Answers: 0
    Also of note this happens on all tables that do not use TH tags to identify column headings, even if you set "bSort" : false
    Regards,
    MIT560
  • tyfytyfy Posts: 2Questions: 0Answers: 0
    Im in APS.NET getting the same error while try to get gridview into data table. My Code is as below. Just the simple 1...
    [code]


    <%--***NOTE... THE CSS STYLESHEET REFERENCED ON THE NEXT LINE DEFINES STYLES
    REQUIRED ONLY BY THIS REPORT. DO NOT CHANGE THIS BLOCK OF HTML. --%>









    $(document).ready(function () {
    $('#GridView1').dataTable();
    });


    <%-- --%>


    [/code]

    Is zero configuration but i can't get my datatable... :( help please.
This discussion has been closed.