-
Notifications
You must be signed in to change notification settings - Fork 754
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
Table sorter storage #389
Comments
Hi @Francks11! I don't think that's a good idea. There are a lot of sites out there that use templates, ajax and/or the developer is just in the habit of naming all of the tables with the same ID - it's a different page, so why not? As the storage code works now, it tries to make sure each table is unique by saving it's url, id and/or index on the page. If I only look for an ID, then every saved parameter, not just "saveSort" will be loaded for different tables. So while I won't make this change, I can tell you that all you need to do is modify your own copy by setting the url to some constant, any constant... just modify this line: url = 3; // window.location.pathname; |
That being said, and I do 100% agree with mottie, seems odd you'd have the same table at a different url anyhow. But couldn't this easily be an option mottie? just a config option that then sets it to a constant, the default obviously staying the same as it is now.
Or something simple like that, not only could it then be a constant but you could then group tables. aka in my site I have lots of tables that are close to the same just different products or mfgs. It's be nice to keep the sort between them, using this approach I could use the same constant per grouping in the init phase. Just a suggestion and it doesn't really chance how it works now. |
Well, I try to keep an open mind. If that'll work for you as an option, then I don't have any problem adding it. |
I haven't testing that code and obviously it's missing all the config section, was just making a suggestion that could make everyone happy. I'm okay either way I have my work arounds for this, but I was just saying I could see it being useful I personally could use it. Then I could finally have a user prefs code that saves the save sort to a db and reloads it for a specific type which is something I have being wanted to do for my users. |
Indeed, being able to specify this option would be really nice :-) I do not like the idea of making changes directly in the copy because if you update, I would have to redo this update. Thank you. |
When this feature will be available? |
Hi @Francks11! I am trying for today... that being said, I would like to get feedback on this proposed change. Since the storage is saving data per page and per table, maybe it would also be nice to modify the table index. I probably went overboard, but here is what I'm thinking: ts.storage = function(table, key, val, options){
var d, k, ls = false, v = {},
c = table.config,
id = options && options.id || $(table).attr(options && options.group ||
'data-table-group') || table.id || $('.tablesorter').index( $(table) ),
url = options && options.url || $(table).attr(options && options.page ||
'data-table-page') || c && c.fixedUrl || window.location.pathname; So now if you have written a custom widget, you can provide options (id & url) or just add a table data attribute: $.tablesorter.storage( table, key, value, {
// table id/group id
id : 'group1',
// table pages
url : 'page1',
// group is overridden by the id option, but sets the table attribute with the ID
group: 'data-table-group',
// page is overridden by the url option, but sets the table attribute with the page/url
page: 'data-table-page'
}); Or, as @TheSin- proposed, just setting a Overkill much? |
Hi @Mottie It is good for me :-). Perfect. This is really much more than what I expected. Thanks |
overkill or super customizable? :) If I get a chance today I'll try and run it through the ringer, I've been so busy on other projects lately :( I really can't wait to get back on this one! |
I would say super customizable :-) |
I forgot to mention, if you use the storage utility to get a stored value AND need to set the storage options, set the // Get key's value from storage with set options
// $.tablesorter.storage( table, key, value, options );
$.tablesorter.storage( $('table')[0], 'someVariable', null, {
id : 'group1'
url : 'page1'
}); Of course, if saving a value, just set the I'll include this detail in the upcoming API docs that I'm adding to the main documentation page. |
Hello,
I use the function "saveSort" of tableSorter and I have encounter a bug/a lack.
The same tablesorter is accessible by two differents url, but it is the same page and the same table.
I see in the source code that the save of sorting depends on the url... :
$.tablesorter.storage = function(table, key, val){$('.tablesorter').index( $ (table) ),
var d, k, ls = false, v = {},
id = table.id ||
url = window.location.pathname;
Is it possible to ensure that it does depend only on the table id?
Thank you
The text was updated successfully, but these errors were encountered: