Basic Column Visibility - invalid colspan when table is empty

Basic Column Visibility - invalid colspan when table is empty

colbrothcolbroth Posts: 3Questions: 3Answers: 0

Problem:
When updating column visibility on an empty table, the formatting is invalid. The issue is, the colspan shown of the empty row is not updated.

Reproduce:
1. Open Basic column visiblity example at https://datatables.net/extensions/buttons/examples/column_visibility/simple.html
2. Hide a few columns so only three columns are displayed
3. In the Search:[] input box, enter text "abcdeg.."
4. An empty table will display showing "No Matching records found"
5. Using developer tools, I see this: <td valign="top" colspan="3" class="dataTables_empty">No matching records found</td>
6. Now click on "Column visibility" button and show five columns
7. Using developer tools, I still see this: <td valign="top" colspan="3" class="dataTables_empty">No matching records found</td>
8. I expected to see: Using developer tools, I see this: <td valign="top" colspan="5" class="dataTables_empty">No matching records found</td>
9. Notice the colspan is not updated to indicate 5 columns are now visible, so the background of the row is now spanned across all columns.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,771Questions: 1Answers: 10,112 Site admin
    Answer ✓

    Thank you!

    Fixed here and it will be in the nightly shortly, and in 1.10.17 which should ship later this week.

    Allan

  • lupa37lupa37 Posts: 2Questions: 0Answers: 0

    Hi, looks like the issue is still there in 1.10.17, 1.10.18, 1.10.19.

    I programmatically exclude some options through button clicks with
    $('#mytables').DataTable().column( 1 ).visible(false)
    .column(1)
    .search( Year>=0?Year:"" )
    .column(2).visible(false)
    .search( Activity_ID>=0?Activity_ID:"" )
    .draw();

    If the previous search gave an empty result
    "No matching record found",
    then the next search has a colspan which goes over the whole table columns area...

  • lupa37lupa37 Posts: 2Questions: 0Answers: 0

    As a quick and dirty workaroud I added after the previous code the following:

    $('.colspanZero').attr('colspan',0);

    along with a class "colspanZero" on all the first "<td>" tags

  • colincolin Posts: 15,154Questions: 1Answers: 2,587

    Hi @lupa37 ,

    I just followed the same steps in the OP on the linked page - this is using the latest 1.10.19 DataTables release - and the colspan is definitely being updated. I also tried with the API as you are, see here, and again it's working as expected.

    Could you modify that example to demonstrate the problem, please.

    Cheers,

    Colin

  • DatatablesnoobDatatablesnoob Posts: 3Questions: 1Answers: 0

    Bug still exists in 1.10.20. Exactly the same symptoms as OP

  • colincolin Posts: 15,154Questions: 1Answers: 2,587

    It's working for me, I followed those steps and the span is now:

    <td valign="top" colspan="5" class="dataTables_empty">No matching records found</td>

    You can see that here. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

This discussion has been closed.