Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hidden columns from column width calculation #371

Closed
ps2goat opened this issue Sep 4, 2013 · 3 comments
Closed

Remove hidden columns from column width calculation #371

ps2goat opened this issue Sep 4, 2013 · 3 comments
Labels

Comments

@ps2goat
Copy link

ps2goat commented Sep 4, 2013

Consider removing hidden columns from the column width calculation. I did this by modifying the following function in jquery.tablesorter.js:

function fixColumnWidth(table) {
    if (table.config.widthFixed && $(table).find('colgroup').length === 0) {
        var colgroup = $('<colgroup>'),
            overallWidth = $(table).width();
        /*  removed hidden elements from the code that determines the width of columns.  added 'remove(":hidden")' below */
        $(table.tBodies[0]).find("tr:first").children("td").remove(":hidden").each(function() {
            colgroup.append($('<col>').css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%'));
        });
        $(table).prepend(colgroup);
    }
}
@thezoggy
Copy link
Collaborator

thezoggy commented Sep 8, 2013

Using the visible selector may be a more elegant solution: http://api.jquery.com/visible-selector/

Elements with visibility: hidden or opacity: 0 are considered visible, since they still consume space in the layout.

@ps2goat
Copy link
Author

ps2goat commented Sep 9, 2013

Good point. I've been busy working other areas of the tablesorter and the filter plugin to also support this with ajax loads, as the code above only works with static versions.

@Mottie
Copy link
Owner

Mottie commented Oct 10, 2013

Hi @ps2goat!

Sorry for the delay.

I'll have this fixed in the next update.

@Mottie Mottie closed this as completed in 636ef9c Oct 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants