-
Notifications
You must be signed in to change notification settings - Fork 755
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
Always sorts using the last column #569
Comments
Hi @driscojs! Hmm, all that code looks like the exact same as from the jsFiddle. Can you provide a demo of this issue? I do wonder if there is some other code on your page that is interfering. |
Happy to supply whatever I can. How would you like me to demo it to you? I can take some screenshots if that’s all you need. I’m not sure about getting access to our site, A: it’s a dev site, B: it’s locked to our logins. I can give you the source view easily enough if that’s good enough. [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] Hi @driscojshttps://github.com/driscojs! Hmm, all that code looks like the exact same as from the jsFiddle. Can you provide a demo of this issue? I do wonder if there is some other code on your page that is interfering. — |
Yeah, I know that makes it more difficult. I don't think screenshots would help in this case. I guess what I'm asking is can you duplicate the problem in a jsFiddle demo? If not, then I would think that there is some other function bound to the table. So, you could start by disabling blocks of unrelated code to see if this issue resolves. Another thing you could do is look to see what events are bound to the table cell. If you are using a newer version of jQuery, type the following into the console and you should see the result below: // enter this into the console (check both the :first and :last th's)
jQuery._data( $('th:first')[0], 'events' );
// this should be the "standard" result
Object {keyup: Array[1], sort: Array[1], mouseup: Array[1], mousedown: Array[1], selectstart: Array[1]}
> keyup: Array[1]
> mousedown: Array[1]
> mouseup: Array[1]
> selectstart: Array[1]
> sort: Array[1]
> __proto__: Object If you see more or less events than those shown above, then there might be other code interfering. You should be able to click on the triangle (shown as |
I entered that console command and got exactly what you listed below for both first and last. We’re on 1.5.2 for jQuery it appears. As for jsFiddle, I copied that code out exactly, since I thought it might be our code as well. I attached the view-source of our page, maybe it’ll help. ☺ |
In case it matters, I just tried with jQuery 1.11 as well, similar results. [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] Yeah, I know that makes it more difficult. I don't think screenshots would help in this case. I guess what I'm asking is can you duplicate the problem in a jsFiddle demohttp://jsfiddle.net/Mottie/abkNM/? If not, then I would think that there is some other function bound to the table. So, you could start by disabling blocks of unrelated code to see if this issue resolves. Another thing you could do is look to see what events are bound to the table. If using a newer version of jQuery, type the following into the console and you should see the result below: // enter this into the console (check both the :first and :last th's) jQuery._data( $('th:first')[0], 'events' ); // this should be the "standard" result Object {keyup: Array[1], sort: Array[1], mouseup: Array[1], mousedown: Array[1], selectstart: Array[1]}
If you see more or less events than those shown above, then there might be other code interfering. You should be able to click on the triangle (shown as > above) in the console to expand each object for more details. — |
Hmm, one more thing to try... Enter the following into your console: $('table').trigger('sorton', [[[0,0]]]); And see if the first column sorts. If it does, I'm not sure what else to tell you beside time to dig through the other code on the page. |
Rob, When I paste that code into the console, it sorts like one would expect. When I change the first digit to 2,0 or 1,0, the corresponding columns sort just fine. Any clue what’s going on? [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] Hmm, one more thing to try... Enter the following into your console: $('table').trigger('sorton', [[[0,0]]]); And see if the first column sorts. If it does, I'm not sure what else to tell you beside time to dig through the other code on the page. — |
Well it sounds like tablesorter is set up properly. The only thing I can think of is that there might be some header cell element being repositioned using css or javascript, or maybe there is content being added using a If that isn't the issue, then I don't think I can be of more help unless I saw the page itself. Maybe you can set me up with a temporary user account - I only need to see it, so I don't need any admin privileges. |
Rob, You can reach the page I’m testing on at http://dashdev.search-mojo.com/tablesorterTest It’s a basic Codeigniter controller with only one function, the index, and that only loads the view. All js, html, css is in the view. We do have a custom base controller, but I’m just extending the CI_Controller directly for this page. I appreciate all the help! [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] Well it sounds like tablesorter is set up properly. The only thing I can think of is that there might be some header cell element being repositioned using css or javascript, or maybe there is content being added using a :before or :after css definition that is covering up header cells. To troubleshoot this, try right-clicking on any of the header cells and "Inspect element" (in Chrome). When you hover over the elements in the development window, it highlights that element on the web page so you can tell if there is any overlapping going on. You can even click on the :after pseudo element in Chrome and see it on the web page. If that isn't the issue, then I don't think I can be of more help unless I saw the page itself. Maybe you can set me up with a temporary user account - I only need to see it, so I don't need any admin privileges. — |
Ok, that is very odd. I did replace the version of tablesorter that was there (v2.15.11) with the latest (v2.15.13) and everything started working - there was an issue with v2.15.11 where the cell indexing was undefined (see #554) and causing problems. Also, the pager plugin isn't being used on that demo page, but it appears to be the same pager plugin provided with v2.0.5b on tablesorter.com. Please update this version if you plan to use the pager. And I wouldn't recommend using the metadata plugin unless you plan to use it. Everything in tablesorter can now be done using data-attributes. |
Rob, Excellent! I’ll give it a try this morning. The pager is probably left in when I copied and pasted, just a silly oversight. The meta, I think I didn’t understand how to use it. Thanks for educating me! Also, thanks for all the patience and troubleshooting! [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] Ok, that is very odd. I did replace the version of tablesorter that was there (v2.15.11) with the latest (v2.15.13) and everything started working - there was an issue with v2.15.11 where the cell indexing was undefined (see #554#554 (comment)) and causing problems. Also, the pager plugin isn't being used on that demo page, but it appears to be the same pager plugin provided with v2.0.5b on tablesorter.com. Please update this version if you plan to use the pager. And I wouldn't recommend using the metadata plugin unless you plan to use it. Everything in tablesorter can now be done using data-attributes. — |
The metadata plugin allows you to set So instead of using this method: headers: {
0: { sorter: false }
} You can use the metadata plugin like this: <th class="{ sorter: false }"></th> The above were the only two options available in the original tablesorter. In this forked version, you can add a class name <th class="sorter-false"></th> or use a data-attribute: <th data-sorter="false"></th> The priority of these setting is data-attribute, metadata, header option then class name (see this demo for more details) |
I’m glad to report all is well now. Just have to figure out how to hide a disabled filter on one column! Everything is sorting like it should! [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] The metadata plugin allows you to set headers optionshttp://mottie.github.io/tablesorter/docs/#headers as a header class name. So instead of using this method: headers: { 0: { sorter: false } } You can use the metadata plugin like this: The above were the only two options available in the original tablesorter. In this forked version, you can add a class name or use a data-attribute: The priority of these setting is data-attribute, metadata, header option then class name (see this demohttp://mottie.github.io/tablesorter/docs/example-parsers-class-name.html for more details) — |
Good to hear! To hide a disabled filter, use this css: .tablesorter-filter.disabled {
display: none;
} |
Already did. :) It worked nicely and we’ve rolled it out to users. [cid:[email protected]] Jeff Driscoll | IT Manager From: Rob G [mailto:[email protected]] Try: .tablesorter-filter.disabled {
} — |
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue this discussion. |
When I put a tablesorter into any table, and click on a column header, it always sorts the final column, instead of that column. I created a test page, and loaded the code straight from the jfiddle provided, and still got the same result. After the page loads, and then I click the 'Numeric' column header, then ctrl-clicking to clear the sort (which does clear it) then I clicked'Animals', this is the console log:
The sort seems to be always sorting the 4th column, #3 of 0-3.
Here's the code I'm using:
Controller:
View:
Apologies if this has been asked already, I swear I looked all over and didn't find it.
I'm trying to implement tablesorter on our internal website, and I'm working with a Codeigniter setup that I didn't create and that programmer is gone, so that might be an issue.
Jeff
The text was updated successfully, but these errors were encountered: