Search the Community
Showing results for tags 'html table'.
-
I've created a table that works responsively across various screen sizes, with columns appearing and collapsing as desired to suit the different devices on which it can be loaded. One issue I'm having, however, regards the `colspan` element. There are instances in which I would like to have a column stretch across an entire row. A quick search of Github has found the following piece of jQuery: $(function() { jQuery.fn.exists = function(){return this.length>0;} // Dynamic Colspan if($('[colspan="auto"]').exists()) { $.each($('[colspan="auto"]'), function( index, value ) { var table = $(this).closest('table'); // Get Table var siblings = $(this).closest('tr').find('th:visible, td:visible').not('[colspan="auto"]').length; // Count colspan siblings var numCols = table.find('tr').first().find('th:visible, td:visible').length; // Count visible columns $(this).attr('colspan', numCols.toString()-siblings); // Update colspan attribute }); } }); Source: https://gist.github.com/afbora/6c98337a3455d45b6ae4e620d5cfbcf2 Here is an example of my table structure: <table> <thead> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td colspan="auto">Divider</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> As you can see, I have a row which makes use of `colspan="auto"` and works fantastically well with the jQuery source from above - automatically expanding to the full width of the row on page load. Where this breaks down, however, is in any instance where a `<td>` has been selected to be hidden in a responsive stylesheet. Instead of switching from `colspan="6"` to `colspan="5"` behind the scenes (DOM), we end up with one row where the colspan is too large. I've looked into `window.onresize`, as I believe the jQuery should run when the browser is made bigger or smaller, but am yet to have any success.
- 5 replies
-
- jquery
- html table
-
(and 1 more)
Tagged with:
-
Hi, bear with me I'm new to this and not too good at learning these days due to ms induced brain fog.... I've been using classic asp code from the tutorials to write a table with data from an access DB, I can get connected to the DB ok and can get all records into a table but can't seem to work out how to get the contents of several fields into the same table data box before going through the loop to write the next table box with the data fields from the next record, I just get a new box for each field, I'm sure it's something simple but I'm just not getting it. Do I need to open a new connection for each table field and how do they nest? I managed to get it to add table row tags every third entry which cheered me up. Thanks in advance for any help.
- 1 reply
-
- classic asp
- MS access
-
(and 2 more)
Tagged with: