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

two header lines issues #1362

Open
assachs opened this issue Feb 24, 2017 · 5 comments
Open

two header lines issues #1362

assachs opened this issue Feb 24, 2017 · 5 comments

Comments

@assachs
Copy link

assachs commented Feb 24, 2017

Hello,
i have some issues with two header lines. I'm not sure, if they belong together

sortList count's second row (http://jsfiddle.net/pehruqqL/1/):
sortList: [[1,0]] sorts the second col of the second row.

headers counts both rows:
http://jsfiddle.net/pehruqqL/2/
headers: {
4: {sorter:false} //first row cols 0 - 2, second cols 3 - 11
}

changing the sorter of the second row has no effect:
headers: {
4: {sorter:'customParser'} //first row cols 0 - 2, second cols 3 - 11
}
(it's working with class-attribute)

@Mottie
Copy link
Owner

Mottie commented Mar 16, 2017

Hi @assachs!

Sorry for not responding earlier. I'm still catching up with issues after returning from vacation.

The issue you've encountered is as intended... a table will always have a set number of columns, but may not always have the same number of header cells.

headers

  • This option targets specific header cells.
  • The zero-based index points to the cell itself.
  • When setting a sorter, the plugin applies the parser to the associated column, unless you use sorter:false which then disables that specific table cell.
  • If more than one sorter definition is set for the same column, the "last" cell in the header assigned to that column will override the other definitions.

sortList

  • This option targets a specific column.
  • The zero-based index points to the column.

I hope that makes things clearer.

@assachs
Copy link
Author

assachs commented Mar 18, 2017

Hello, thanks for your reply. I hope you had good vacations ;)

I understand the difference between headers and and sortlist now. But i still think there is a problem with headers and two header rows.

Look at the following examples:
All of them use a custom parser to sort 01,03, 2 instead of 01, 2, 03

http://jsfiddle.net/ke52bbf1/
The parser is added to the last column with class attribute. It is also added to 3 (4th column) with "headers"-option. It is working for both columns.

Now, i have a two header row example:
http://jsfiddle.net/g6srzo87/
The parser is added to the last column with class attribute. It's working.
The parser is added to cell 3 (= second column). It is NOT working. I think the second column should be the associated column.

@Mottie
Copy link
Owner

Mottie commented Mar 18, 2017

The problem is that the headers must be set as if the index is of all header cells. The third column header cell is represented by "Cell 4" which has a (zero-based) index of 4.

Hmm, yes it does appear that there is a problem with the way the headers option is being parsed when there are multiple header rows. I could fix it, but if I did it would break all backwards compatibility 😿 I'll fix when I get to work on Abelt again.

To get around this problem, set the parser by data-attribute, class name or completely disable the first header row by adding a class name of "tablesorter-ignoreRow" to the <tr>; but this also disables sorting.

@JohnSmall
Copy link

With two row headers I found I could add the sort buttons only to the second row, not the first row by setting

`selectorHeaders: '> thead > tr:last-child > th'`

But If I then want to set some columns not to be sorted e.g.

headers: {0: {sorted: false}}

Then the first column is still sortable.

But if I don't set selectorHeaders then I can disable some columns, but only for the first row.

If I use the class name "tablesorter-ignoreRow" on the first in the header then it disables sorting for that row, leaves sorting for the other row, but doesn't allow me to set columns not to be sorted.

@Mottie
Copy link
Owner

Mottie commented Jan 31, 2018

Hi @JohnSmall!

The key should be set to sorter not sorted - demo

headers: {
  0: { sorter: false }
}

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

3 participants