DataTables / Responsive

Responsive extension for DataTables, providing support for complex tables on all device screen sizes
Other
148 stars 86 forks source link

Some styles should not be applied when empty table #50

Closed pmalouin closed 8 years ago

pmalouin commented 8 years ago

In the generated css, here are the styles that leave room for the row expansion button:

table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child,
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child {
  position: relative;
  padding-left: 30px;
  cursor: pointer;
}

These selectors incorrectly match the empty data element (ex. when empty data returned from server):

<tbody>
   <tr class="odd">
      <td valign="top" colspan="5" class="dataTables_empty">No data available in table</td>
   </tr>
</tbody>

The three styles should not be applied (cursor should not be pointer, padding-left messes with the text-align:center of the .dataTables_empty).

Altering the selectors like this should work:

table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child:not(.dataTables_empty),
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child:not(.dataTables_empty) {
  position: relative;
  padding-left: 30px;
  cursor: pointer;
}

I also fixed the styling for when the compact class is applied.

DataTables commented 8 years ago

Nice one - thanks for this! Are you happy for this to be included under the MIT license?

pmalouin commented 8 years ago

Yes I am.

DataTables commented 8 years ago

Ace - thanks :-)