DataTables - Not working when added colspan for the last column

后端 未结 4 503
不知归路
不知归路 2020-11-30 08:52

I\'ve a problem using DataTables. When i add colspan for the last column, the datatable plugin wont get applied to the table. If i remove the colspan for the last one and pu

4条回答
  •  攒了一身酷
    2020-11-30 09:21

    dataTable does not support colspan or rowspan.

    If you use a colspan, dataTable won't understand the columns count / calculation, returning undefined and throwing an error in that case.

    So what we need to do, is tell dataTable that in case it doesn't get the expected result, what should be the alternative one.

    For that we will use: defaultContent property, and of course expecifying the targets / affected columns.

    For example: on a table with 3 td's if we use td colspan="2", we will have to set the default values for the other 2 (because one already exists - and it's the first).

    Code:

    "aoColumnDefs": [{
      "aTargets": [2,3],
      "defaultContent": "",
    }]
    

提交回复
热议问题