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

sorting sorts cells, not rows #88

Closed
strager opened this issue May 18, 2023 · 3 comments
Closed

sorting sorts cells, not rows #88

strager opened this issue May 18, 2023 · 3 comments
Assignees

Comments

@strager
Copy link
Contributor

strager commented May 18, 2023

I have some row-specific data- attributes which I use in my JS code:

<tr class="func" data-func-index="0">
<td>callee</td><td>0</td><td></td>
</tr>
<tr class="func" data-func-index="1">
<td>caller</td><td>72</td><td></td>
</tr>
<tr class="func" data-func-index="2">
<td>_DllMainCRTStartup</td><td>32</td><td></td>
</tr>

The data is attached to each <tr>. I have a click event listener on the entire table which finds the clicked <tr> and uses its data-func-index to show details.

table-sort-js breaks my table. When the user clicks on a column header, the data cells are sorted properly, but the data- attributes are not adjusted accordingly. data-func-index="0" should always be associated with the "callee" row, but after sorting by the second column (for example) it can be attached to a different row such as the "caller" row:

<tr class="func" data-func-index="0">
<td>caller</td><td>72</td><td></td>
</tr>
<tr class="func" data-func-index="1">
<td>_DllMainCRTStartup</td><td>32</td><td></td>
</tr>
<tr class="func" data-func-index="2">
<td>callee</td><td>0</td><td></td>
</tr>
@LeeWannacott
Copy link
Owner

LeeWannacott commented May 18, 2023

Fixed in #89: 1.15...1.15.1

Could possibly use a feature flag if use case for being static in place like applying CSS classes...

Still needs to be fixed for file-size-sort class...

@LeeWannacott
Copy link
Owner

file-size-sort now sorts rows thanks to strager 🥇 #98

@LeeWannacott
Copy link
Owner

I added option https://github.com/LeeWannacott/table-sort-js/pull/108/files for cells-sort rather than tr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants