Uncaught TypeError: Cannot read property 'aDataSort' of undefined

前端 未结 5 1706
独厮守ぢ
独厮守ぢ 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:24

    use something like the following in your code to disable sorting on DataTables (adapted from a project of mine which uses latest DataTables)

    $(document).ready(function() {
         $('.datatable').dataTable( {
            'bSort': false,
            'aoColumns': [ 
                  { sWidth: "45%", bSearchable: false, bSortable: false }, 
                  { sWidth: "45%", bSearchable: false, bSortable: false }, 
                  { 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, adjust as needed for your own table (number of) columns.

提交回复
热议问题