Skip to content
New issue

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

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

Already on GitHub? # to your account

How to make more than 1 row sticky? #52

Closed
megatom opened this issue Apr 19, 2012 · 15 comments
Closed

How to make more than 1 row sticky? #52

megatom opened this issue Apr 19, 2012 · 15 comments

Comments

@megatom
Copy link

megatom commented Apr 19, 2012

I want make more than 1 row of my table sticky.
If i put 3 TR in the THEAD with TH inside tablesorter just makes the last row sticky.
If i put 1 TR with TH and 2 TR with TD it makes only the 1 with TH sticky.
But how can I make all of my TR in THEAD sticky?

@Mottie
Copy link
Owner

Mottie commented Apr 19, 2012

The way the widget works now, it only makes one row sticky because I was trying to prevent it from interfering with the other widgets, like the filter. I'll look into adding more sticky headers when I have some time.

@Mottie
Copy link
Owner

Mottie commented Apr 20, 2012

Hi megatom!

Check out the latest version (2.1.16) which now works with multiple sticky rows. I've also updated the sticky header demo.

@megatom
Copy link
Author

megatom commented Apr 21, 2012

Hello,
If I update from 2.1.15 to 2.1.16 none of my tablesorter ist working :(
In firebug i get error: h is undefined

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2012

Hi. are you putting <td>'s in the header? The sticky header widget won't work properly if you do.

If not, could you share a bit more information... like the header HTML, initialization settings, and if it is occurring in all browsers or just one. Thanks.

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2012

Hmm, ok try doing this, I think it'll make the sticky header widget work with <td>'s....

$('table').tablesorter({
    // get both TH's and TD's from the table header
    selectorHeaders: 'thead th, thead td',
    widgets: [ 'zebra', 'stickyHeaders' ]
});

@megatom
Copy link
Author

megatom commented Apr 21, 2012

Hi,
sorry i dont mean that sticky headers dont work but NONE of the tablsorter functions like sorting etc...

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2012

Then I need some code.

@megatom
Copy link
Author

megatom commented Apr 21, 2012

OK, for example on this site:
http://www.deine-berge.de/av_beitraege.php

@megatom
Copy link
Author

megatom commented Apr 21, 2012

Sorry, i have to downgrade the site to 2.1.15, because none of my scripts are working with 2.1.16 and this site is no test page ;)

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2012

Ok, try the 2.1.17 update. It works.

@megatom
Copy link
Author

megatom commented Apr 21, 2012

2.1.17 seeems to work with 2 sticky rows, but may have some problems with filter :(
http://www.deine-berge.de/av_beitraege.php

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2012

If I replace this code in the d-b.js file:

$(".sortable").tablesorter({ widgets: [ 'stickyHeaders' ] });

if($(".sortableFilter").length){
  // Update the list of widgets to apply to the table (add or remove)
  $(".sortableFilter").data("tablesorter").widgets = ['filter'];
  // This method applies the widget - no need to keep updating
  $('.sortableFilter').trigger('applyWidgets');
}

with this:

$(".sortable").tablesorter({
  selectorHeaders: 'thead th, thead td',
  widgets: [ 'filter', 'stickyHeaders' ]
});

then add this css:

.sortable thead tr {
  background: #fff;
}

Once that is done, the filter widget does add a few extra inputs... so I will need to modify the sticky and filter widgets. Give me a few minutes.

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2012

I kept the same version number and just updated the widget.js file.

@megatom
Copy link
Author

megatom commented Apr 21, 2012

Great job! Works fine now for me.
Maybe you could integrate a class like sticky-false on TR in THEAD in a later version, if someone doesnt want to make all rows sticky.
But not necessary for me so far.
Thank you!

@Mottie
Copy link
Owner

Mottie commented Apr 23, 2012

I've added the sticky-false option you suggested into version 2.1.18. Thanks again!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants