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

Support colspan and td's in thead #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions coffee/sortable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ sortable =

table.setAttribute 'data-sortable-initialized', 'true'

ths = table.querySelectorAll('th')

for th, i in ths
if th.getAttribute('data-sortable') isnt 'false'
i = 0
for th in table.tHead.rows[0].cells
if th.getAttribute('data-sortable') isnt 'false' and th.tagName is 'TH'
sortable.setupClickableTH table, th, i
i += th.colSpan

table

Expand Down Expand Up @@ -84,11 +84,17 @@ sortable =
_compare a[0], b[0]

for row, position in tBody.rows
value = sortable.getNodeValue(row.cells[i])
if type.comparator?
value = type.comparator(value)
j = 0

for cell in row.cells
if j == i
value = sortable.getNodeValue(cell)
if type.comparator?
value = type.comparator(value)

rowArray.push [value, row, position]

rowArray.push [value, row, position]
j += cell.colSpan

rowArray.sort compare
tBody.appendChild row[1] for row in rowArray
Expand Down
44 changes: 27 additions & 17 deletions js/sortable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/sortable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.