How can I write more columns than defined in header?

Viewed 56

I am using Datatables jQuery plugin and I have the following columns in html:

<tbody>
    <td class="test1">elem1</td>
    <td class="test2" style="display: none;">elem2</td>
</tbody>

I activate one or the other column from jQuery ( always one ). Problem is that 'datatables' plugin yells error because num of columns from tbody is not equal with num of columns from thead (1 in my case 'cause I only want one to display).

Is there a workaround for defining more columns than specified in the header and pass validation ?

  1. I am writing the html thought Django's template language.
  2. For showing columns I use something like this:
 <select onchange="selectChange(this.value)">
    <option>test1</option>
    <option>test2</option>
 </select>


function selectChange(val) {
  $(`[class*="test"]`).hide();
  $(`[class="${val}"]`).show();
}
0 Answers
Related