Is it possible to perform colspan on Datatables?

Asked

Viewed 424 times

0

I have the following structure in PHP implementing a table:

foreach ($varConsulta as $lin) {
    $var1= $varConsulta[$i]['1'];
    $var2= $varConsulta[$i]['2'];
    $var3= $varConsulta[$i]['3'];
    $varFase= $varConsulta[$i]['FASE'];

    $linhas = "";
    $linhas .= "<td style='padding: 10px;'>" . utf8_encode($var1) . "</td>";
    $linhas .= "<td style='padding: 10px;'>" . utf8_encode($var2) . "</td>";
    $linhas .= "<td style='padding: 10px;'>" . utf8_encode($var3) . "</td>";

    switch ($varFase) {
        case 1:
            $linhas .= "<td colspan='2'>ALUNO NÃO APROVADO</td>";
            break;
        case 2:
            $linhas .= "<td style='padding: 10px;'><select id='".$var1."' name='".$var1."'><option value=''></option><option value='1'>SIM</option><option value='0'>NÃO</option></select></td>";
            $linhas .= "<td style='text-align: center;'><a href='#' onclick='comparecimento(".$var1.")' class='Adicionar' title='Adicionar'>.</a></td>";
            break;
        case 3:
            $linhas .= "<td colspan='2'>AGUARDANDO RESULTADO</td>";
            break;
    }

    echo "<tr>" . $linhas . "</tr>";
    $i++;
}

I would like to know if there is a configuration of dataTable allowing the concatenation of columns in the corpo da tabela, and not in the header

Here’s the default setting I use on dataTable:

if ($("#lst").length){

    $("#lst").dataTable( {
        "bJQueryUI" : true,
        "sPaginationType" : "full_numbers",
        "iDisplayLength": 10
    });
}

2 answers

3

unfortunately it is currently not possible to perform colspan in table rows by datatables, below follows an explanation given by a member of the development team:

I’m Sorry to Say that Datatables does not support colspan at the Moment. The Reason for this is that it is very Much a non-trivial problem in how this would Interact with Filtering and Sorting (for example how would you Sort a column which has Elements that span Multiple Columns - which column would that data Belong to? The first one, or all of them? - The same Question hangs over Filtering).

reference: http://datatables.net/forums/discussion/14/datatables-and-colspan

if you need translation then request but I believe that the google translator can handle.

0

One way to do this would be to add in cells:

<th style="width: 40%;">Nome</th>
<td style="width: 40%;">resultado)</td>
  • But I believe that this does not actually create an effect of colspan, only increases column width

Browser other questions tagged

You are not signed in. Login or sign up in order to post.