i believe this has never really worked correctly. basically, the issue is that the tablesorting code was only built to handle one table. attached patch adds an optional 'id' arg to both the tablesort_sql and theme_table functions. this allows for properly identifying sorting parameters per table. you can even sort mutliple tables in different ways, and the sorting parameters for each table will be preserved!

i was torn on whether to use an internal id for the table, or to allow the dev to specify. i chose allowing the dev to specify, but it probably wouldn't be too hard to change it to the other method if that's what we prefer.

to properly id a table, you need to specify the id arg in both of the above mentioned functions. i really didn't see a better way to do it, since the sql generation and theming generation are pretty separate.

note that this does not break any existing table code--if an id isn't specified, then things work the way they always have.

this is probably a borderline critical issue. i suppose it could be deemed an API change, or not critical b/c the functionality has never worked correctly. somebody knock me down if i'm out of line... :)

CommentFileSizeAuthor
tablesort.patch5.6 KBhunmonk

Comments

merlinofchaos’s picture

Looks like a reasonable solution to me.

I don't, however, feel this is really 'critical'.

chx’s picture

Priority: Critical » Normal

This is definitely not critical. Also, this changes API... though the usual entrypoints are indeed BC.

chx’s picture

Version: x.y.z » 5.0-beta1
drumm’s picture

Status: Needs review » Fixed

Committed to HEAD.

hunmonk’s picture

for anyone interested, i added a short example on how to use this in the module how-to section of the handbook:

http://drupal.org/node/98097

dries’s picture

This is not a bug report but a new feature. I also am not particularly fond of the implementation.

dries’s picture

Version: 5.0-beta1 » 6.x-dev
Category: bug » feature
Status: Fixed » Postponed

I'm rolling this back. It's a new feature and not a bug report. This has been an intentional limitation for many years. Having multiple sortable tables on one page is only useful for mega-pages which should be avoided to begin with. Not being able to put two sortable pages on one page is a _good_ restriction. Sorry but I consider this patch to be cruft.

Either way it is an API change and a feature request, not a bug report and far from critical.

hunmonk’s picture

Status: Postponed » Needs work

dries: i'm happy to rework the implementation to suit your needs--the patch was a first attempt at solving a usability issue. i do, however, think it's debatable that it's a good restriction. in my view there are certainly use cases where having more than one table on a page is perfectly valid, and leaving tablesorting broken for that case is, IMHO, a worse solution than the initial one i proposed... ;)

since i'd like to see this fixed in drupal 6, i'm moving it out of the postponed category. if anybody has suggestions on a better approach than the one i initially posted, please chime in with thoughts, and i'll try to work up another patch when the dev branch opens for 6.0

BioALIEN’s picture

I believe this is a valid fix to a problem/limitation present in the existing limitation of the tablesorting.

Recently I was required a stack of 10+ tables on a page, each with their individual sorting methods . I used a JS implementation in the end but it would have been nice to have a server-side fall over for it via drupal tablesort.

hunmonk’s picture

Assigned: hunmonk » Unassigned

i still think this should be properly fixed, but i'm not going to champion it anymore. hopefully somebody else will pick it up.

moshe weitzman’s picture

When a developer goes out of his way to add multiple tables to a page, Drupal should not reject him with a red " i know this is bad for usability" card. I'd like to see this fix go in. The framework part of Drupal needs this sort of thing.

BioALIEN’s picture

I couldn't agree more. Anyway, now that FAPI3 is in place, should this fix be done at the API level? Would love to have this in D6, but not sure where it stands with the feature freeze.

merlinofchaos’s picture

BioALIEN: No, tables are only occasionally used for forms. This isn't really related to FAPI.

pasqualle’s picture

Version: 6.x-dev » 7.x-dev

if someone can make it without api change, than go on, but otherwise 7.x

Jaza’s picture

Version: 7.x-dev » 8.x-dev

AFAIK this is still an issue, still waiting for someone to pick it up and give it some TLC again. Maybe 8.x, eh?

timmillwood’s picture

I have just ran into this issue when trying to add a 'content' and 'comments' table blocks to a content creator dashboard.

jaypan’s picture

This is a feature I would like to see implemented. I have created two tables for the Force Password Change module. One showing a list of users with a pending password change, the other showing a list of users without the pending password change. As the table headers are the same, both tables are affected when choosing to sort by any column in either of them.

pager_query.inc has a method for identifying multiple tables on a page, I feel that tablesort.inc should also contain a method for this.

dawehner’s picture

Component: base system » database system
Issue summary: View changes

.

dawehner’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed 4f0f376 on 8.3.x
    - Rollback of #94058: see issue.
    
    
  • drumm committed 761b0c7 on 8.3.x
    #94058 by hunmonk. Allow for multiple sortable tables on a page.
    
    

  • Dries committed 4f0f376 on 8.3.x
    - Rollback of #94058: see issue.
    
    
  • drumm committed 761b0c7 on 8.3.x
    #94058 by hunmonk. Allow for multiple sortable tables on a page.
    
    

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed 4f0f376 on 8.4.x
    - Rollback of #94058: see issue.
    
    
  • drumm committed 761b0c7 on 8.4.x
    #94058 by hunmonk. Allow for multiple sortable tables on a page.
    
    

  • Dries committed 4f0f376 on 8.4.x
    - Rollback of #94058: see issue.
    
    
  • drumm committed 761b0c7 on 8.4.x
    #94058 by hunmonk. Allow for multiple sortable tables on a page.
    
    

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

  • Dries committed 4f0f376 on 9.1.x
    - Rollback of #94058: see issue.
    
    
  • drumm committed 761b0c7 on 9.1.x
    #94058 by hunmonk. Allow for multiple sortable tables on a page.
    
    
daffie’s picture

Status: Needs work » Fixed
daffie’s picture

Status: Fixed » Closed (fixed)