Uncaught TypeError: Cannot read property 'aDataSort' of undefined

前端 未结 5 1716
独厮守ぢ
独厮守ぢ 2020-12-18 01:00

i am working on pagination and i am using DataTables plugin , on some tables it\'s work but on some tables it gives error:

Uncaught TypeError: Cannot

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-18 01:36

    I had faced a similar issue when binding data table to a .Net GridView if grid view did not have any data and no header values defined then it was throwing:

    Uncaught TypeError: Cannot read property 'aDataSort' of undefined
    

    Below was the code for the same.

    $("#GridView1").prepend($("").append($("#GridView1").find("tr:first"))).dataTable();
    $("#GridView1").dataTable();
    

    I guess you are also facing the same issue, as you are also getting the table header names dynamically and if the result for it is null or empty then you are getting the mentioned error. Therefore, either you try giving column names when binding it to data table or make sure that your PHP code always returns some data for the table header.

提交回复
热议问题