How to use colspan to buttons

How to use colspan to buttons

mudolrdmudolrd Posts: 1Questions: 1Answers: 0

Hey im trying create a simple table

<thead>
    <tr>
        <th>Name</th>

        <th colspan="2" class="text-center">Tools</th>
    </tr>
</thead>

<tbody>
<tr>
    <td>Name</td>
    <td class="text-center">
        <a href="" class="btn btn-info">
            <i class="fa fa-pencil"></i>
        </a>
    </td>
    <td class="text-center">
        <a href="" class="btn btn-danger">
            <i class="fa fa-trash-o"></i>
        </a>
    </td>

But I got "TypeError: c is undefined"

If i change it to

<thead>
    <tr>
        <th>Name</th>

        <th class="text-center">Tools</th>
        <th class="text-center">Tools</th>
    </tr>
</thead>

<tbody>
<tr>
    <td>Name</td>
    <td class="text-center">
        <a href="" class="btn btn-info">
            <i class="fa fa-pencil"></i>
        </a>
    </td>
    <td class="text-center">
        <a href="" class="btn btn-danger">
            <i class="fa fa-trash-o"></i>
        </a>
    </td>

It worked

Can anyone help me, Thank You

Answers

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,736

    Colspan is supported with Datatables but there also needs to be one TH cell per column. This is described in this example:
    https://datatables.net/examples/basic_init/complex_header.html

    In your case why don't you put both buttons into one column and not use colspan?

    Kevin

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    You could also have an additional header cell with nothing in it which would work. As Kevin rightly says, there needs to be a unique cell for each column in the table.

    Allan

This discussion has been closed.