tabledrag.js doesn't play nice with nested tables

berenddeboer - November 4, 2008 - 03:17
Project:Drupal
Version:6.x-dev
Component:javascript
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi All,

If I have a nested table inside a draggable table I get the following error:

cell[0] is undefined
[Break on this error] if (cell[0].colSpan > 1) {

Looking at the source, it seems to me the columnIndex and headerIndex calculation should be based in the immediate element of their parent, or not? So the correct selector would be:

      var columnIndex = $('> td', cell.parent()).index(cell.get(0)) + 1;
      var headerIndex = $('> td:not(:hidden)', cell.parent()).index(cell.get(0)) + 1;

(I added the "> " part).

Anything I didn't think off? This seems to work so far.

#1

berenddeboer - November 4, 2008 - 03:19

BTW, the line number where the error occurs is 130.

#2

berenddeboer - November 7, 2008 - 02:14

I've attached a patch that even allows for nested dragged tables. Obviously this needs some intricate support on the server side as well.

AttachmentSizeStatusTest resultOperations
tabledrag.patch2.67 KBIdleFailed: Failed to apply patch.View details | Re-test

#3

chx - June 4, 2009 - 02:30
Version:6.6» 7.x-dev

Let's fix first in D7 and then backport.

#4

System Message - June 4, 2009 - 02:35
Status:needs review» needs work

The last submitted patch failed testing.

#5

danielb - June 4, 2009 - 02:39
Version:7.x-dev» 6.6
Status:needs work» reviewed & tested by the community

This patch works for me mate. I've worked for 3 weeks on a module with the assumption I could make nested drag tables - you can imagine the rude shock I copped when I tried various ways to nest tables.

Using your patch I am able to achieve what I need using the simplest technique - a FAPI array element within the 'value' FAPI array element of one dragtable row.

The problem now I that I cannot distribute my module until this bug is fixed in D6 core, or if I hack together a 2nd JS file that will install with my module - but then I will need to rewrite other tabledrag functions, probably.

Is there a chance this can be added to a D6 release, and how can I help?

#6

danielb - June 4, 2009 - 02:43
Version:6.6» 7.x-dev
Status:reviewed & tested by the community» needs work

sorry chx, I type slow

So - the patch failed testing - what is wrong with it?

#7

redndahead - June 4, 2009 - 02:41

Please don't change the version. We first need to patch core and then we'll backport and apply if necessary. It also needs to pass testing before it can be moved to RTBC.

#8

danielb - June 4, 2009 - 02:47

Not my fault mate, looks like this forum has a concurrent update bug.

#9

redndahead - June 4, 2009 - 02:52

I guess I typed slow too. :) It happens. It's not a bug it's a feature. :)

Attached patch for D7

AttachmentSizeStatusTest resultOperations
draggable-329797-1.patch2.45 KBIdlePassed: 11628 passes, 0 fails, 0 exceptionsView details | Re-test

#10

redndahead - June 4, 2009 - 02:55
Status:needs work» needs review

Son of a monkey I swear I switched that to CNR.

@danielb you can help by testing this works in d7. I haven't tested it I just took the code from before.

#11

danielb - June 4, 2009 - 02:59

Thanks, I will write a nested drag table in Drupal 7.

#12

danielb - June 4, 2009 - 23:38
Status:needs review» reviewed & tested by the community

I can confirm that prior to applying the patch in Drupal 7 I was experiencing the same problem I had in Drupal 6. After applying the patch the behaviour was as originally expected.

For completeness I have attached the module I hacked together for this review, it's a bit rough as I had some trouble with theme_form_element, and may have misused drupal_render() to get around it, but that is just my inexperience with Drupal 7.

AttachmentSizeStatusTest resultOperations
dragtest.zip1.86 KBIgnoredNoneNone

#13

Dries - June 5, 2009 - 16:37
Status:reviewed & tested by the community» needs work

Would be great if we could document this a bit better in the code. It wasn't immediately obvious... Quick re-roll with some code comments?

#14

danielb - June 6, 2009 - 01:57

Something like "match immediate children of the parent element to allow nesting"? Or more detailed? Should it be put in all four blocks of changed code?

#15

danielb - June 8, 2009 - 23:54
Status:needs work» needs review

Patch with added comments.

AttachmentSizeStatusTest resultOperations
draggable-329797-2.patch2.74 KBIdlePassed: 11628 passes, 0 fails, 0 exceptionsView details | Re-test

#16

danielb - June 9, 2009 - 23:58
Status:needs review» reviewed & tested by the community

#17

Dries - June 10, 2009 - 05:07
Version:7.x-dev» 6.x-dev
Status:reviewed & tested by the community» needs review

Committed to CVS HEAD. Thanks. Moving version to D6

#18

moshe weitzman - June 10, 2009 - 19:49

Can we use this anywhere in core? Where are folks thinking of using this? screenshot?

#19

danielb - June 10, 2009 - 23:29

I am not sure a need exists to do a nested table in core, but since people like me need it for contrib modules, and the original poster needed it for his website, it shouldn't be prevented by a design that assumes no nesting.

The concept of nesting and hierarchies pops up constantly in development of all sorts of things. My need is for a user to configure a list of things that will happen. Some of these things have a sublist of processes that have to be ordered too. One solution is to have a seperate page for each sublist - but when the sublist is not important enough to have its own page, a nested table seems like the most convenient option for an interface.

Do we need to create a new patch for D6 with the comments, or will it be right?

#20

redndahead - June 11, 2009 - 03:20

A new patch will need to be created against D6

#21

danielb - June 14, 2009 - 10:08
Status:needs review» reviewed & tested by the community

This is the D6 version of the patch.

AttachmentSizeStatusTest resultOperations
draggable-329797-3.patch2.75 KBIgnoredNoneNone

#22

Gábor Hojtsy - June 18, 2009 - 12:24
Status:reviewed & tested by the community» fixed

Committed to Drupal 6, thanks.

#23

System Message - July 2, 2009 - 12:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.