jquery datatable display No data available in table after creting table Row runtime(javascript)

前端 未结 3 630
后悔当初
后悔当初 2021-01-22 03:29

i am trying to display table(Jquery DataTable) of data witch i created from JavaScript but some how the table is display like this .

3条回答
  •  暖寄归人
    2021-01-22 04:16

    It seems you are adding the rows manually and I am not sure that will work well with datatables. I recommend you read there api and if you insist on doing it this way you can use fnAddData, straight from the site the usage looks like:

    var giCount = 2;
    $(document).ready(function() {
      $('#example').dataTable();
    } );
    
    function fnClickAddRow() {
      $('#example').dataTable().fnAddData( [
      giCount+".1",
      giCount+".2",
      giCount+".3",
      giCount+".4" ]
    );
    
    giCount++;
    

    }

    you can then still style the table through css.

提交回复
热议问题