concatenat data tables coums

2019-09-04 02:23发布

问题:

i try to create table through jquery now i successfully display table and data

if (re.length > 0) {
    $("#services_schdulue").append
    $('#services_schdulue thead').append(
        "<tr><th>Conactenate</th><th>frequency</th><th>FDuration</th><th>FMileage</th><th>Lperformed</th><th>Nddatetime</th><th>Ndmileage</th><th>Rfrequ</th><th>Rduration</th><th>RMileage</th></tr>"
    );

    for (var i = 0; i < re.length; i++) {
        if (re[i] !== null) {
            $('#services_schdulue tbody').append(
                '<tr><td>' + con  +
                '</td><td>' + re[i][0] +
                '</td><td>' + re[i][1] +
                '</td><td>' + re[i][2] +
                '</td><td>' + re[i][3] +
                '</td><td>' + re[i][4] +
                '</td><td>' + re[i][5] +
                '</td><td>' + re[i][6] +
                '</td><td>' + re[i][7] +
                '</td><td>' + re[i][8] +
                '</td><</tr>');
        }
    }
}

var myTable = $('#services_schdulue').DataTable();

I try to to concatenate like this

var con = re[i][0].concat(re[i][1], re[i][2]);

but this show wrong result this show result like this:

First column should be 6 month(s) 1000.

How to do that?

回答1:

You need to use colspan property of the datatable:

For Demo :

http://jsfiddle.net/dipakthoke07/sgyzfw79/1/

Stack overflow : DataTables - Not working when added colspan for the last column

Datable official:

https://datatables.net/examples/basic_init/complex_header.html