The idea is this :
I have one jQuery that loads the DataTables, and I know that I can set the “aoColumns” : “sWidth” parameter to make one column fixed width and it’s working.
The problem that I have is that I have a lot of tables, variable numbers of columns, and I need the LAST one to be fixed size, no matter what number that column is. Sometimes can be 3rd, sometimes can be 8th, sometimes can be 16th, does not matter.
Is even possible ?
No, I don’t want to call datatable jQuery for each table, no I don’t want to modify anything in the structure because it’s working very well right now, just maybe add some class or parameters to the Javascript.
Structure your tables like this:
That way, your jQuery will just need to do this:
That jQuery will find the last column in each table with that class, and do whatever you want with that last class on each one. (I just used the background-color to test it out.)
If all you’re doing is just setting the width, you might be able to get away with doing
$(self).find('th:last'), but the<colgroup>and<col>is the “correct” way to go.