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

headerTemplate and cssIcon should not be applied when th is declared as non-sortable #1409

Closed
Antoniossss opened this issue May 31, 2017 · 4 comments

Comments

@Antoniossss
Copy link

Antoniossss commented May 31, 2017

So if I have following headers:

                    <th>Complete</th>
                    <th>Incomplete</th>
                    <th data-sorter="false">Complete </th>
                    <th data-sorter="false">Incomplete</th>

And i iniliatize tablesorter like that:

 $(val).tablesorter({
            cssIconAsc: 'fa fa-caret-up',
            cssIconDesc:'fa fa-caret-down',
            cssIconNone:'fa fa-sort',
            headerTemplate:'{content} {icon}'
        })  

All headers including non-sortable gets cssIconNone appended.

Right now as a woraround, I removed headerTemplate from settings and manually setup sortable headers like this:


                     <th>Complete <i class="tablesorter-icon fa fa-sort"/></th>
                     <th>Incomplete <i class="tablesorter-icon fa fa-sort"/></th>

Is this a bug? Or am I using tablesorter wrong?

@Mottie
Copy link
Owner

Mottie commented May 31, 2017

Hi @Antoniossss!

The headerTemplate will apply to all headers by default, as you might want to have an icon showing in a disabled header. You can modify this behavior using the onRenderTemplate callback; the index parameter matches the index of the header and not necessarily the column when you have more than one header row.

There is also a onRenderHeader callback which can be used to manipulate the header contents.

When a column is disabled, a sorter-false class name is always added. You can use this to alter the style of the disabled header.

Given the above information, I could see a benefit in adding a new cssIconDisabled option.

@Antoniossss
Copy link
Author

Antoniossss commented May 31, 2017

This would very handy and clean solution like adding data-cssIconDisabled='' or false. to markup meaning no icon as well as "no sort" icon you have mentioned. Good to know it is not a bug just a lack of feature. Consider it a feature request :) Thank you quick replay, and keep up the good work!

@Mottie
Copy link
Owner

Mottie commented May 31, 2017

A cssIconDisabled option has been added and is now available in the master branch.

I'm not sure where data-cssIconDisabled='' came from as the cssIcon options are not currently available to be set using a data-attribute. Did you need a different disabled icon depending on the column? I think this might be an edge case and would be better handled using the onRenderHeader callback.

@Mottie
Copy link
Owner

Mottie commented Jun 2, 2017

Version 2.28.13 is now available.

@Mottie Mottie closed this as completed Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants