JQuery Datatables : Cannot read property 'aDataSort' of undefined

前端 未结 8 1980
日久生厌
日久生厌 2020-12-02 21:43

I created this fiddle to and it works well as per my requirements: Fiddle

However, when I use the same in my application I get an error in the browser console saying

8条回答
  •  暖寄归人
    2020-12-02 22:32

    I faced the same problem, the following changes solved my problem.

    $(document).ready(function() {
         $('.datatable').dataTable( {
                bSort: false,
                aoColumns: [ { sWidth: "45%" }, { sWidth: "45%" }, { sWidth: "10%", bSearchable: false, bSortable: false } ],
            "scrollY":        "200px",
            "scrollCollapse": true,
            "info":           true,
            "paging":         true
        } );
    } );
    

    the aoColumns array describes the width of each column and its sortable properties.

    Another thing to mention this error will also appear when you order by a column number that does not exist.

提交回复
热议问题