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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

berenddeboer’s picture

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

berenddeboer’s picture

FileSize
2.67 KB

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

chx’s picture

Version: 6.6 » 7.x-dev

Let's fix first in D7 and then backport.

Status: Needs review » Needs work

The last submitted patch failed testing.

danielb’s picture

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?

danielb’s picture

sorry chx, I type slow

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

redndahead’s picture

Version: 6.6 » 7.x-dev
Status: Reviewed & tested by the community » Needs work

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.

danielb’s picture

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

redndahead’s picture

FileSize
2.45 KB

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

Attached patch for D7

redndahead’s picture

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.

danielb’s picture

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

danielb’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.86 KB

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.

Dries’s picture

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?

danielb’s picture

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?

danielb’s picture

Status: Needs work » Needs review
FileSize
2.74 KB

Patch with added comments.

danielb’s picture

Status: Needs review » Reviewed & tested by the community
Dries’s picture

Version: 7.x-dev » 6.x-dev
Status: Reviewed & tested by the community » Needs review

Committed to CVS HEAD. Thanks. Moving version to D6

moshe weitzman’s picture

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

danielb’s picture

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?

redndahead’s picture

A new patch will need to be created against D6

danielb’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.75 KB

This is the D6 version of the patch.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Committed to Drupal 6, thanks.

Status: Fixed » Closed (fixed)

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

jsagotsky’s picture

FileSize
2.75 KB

The third version of the patch wasn't working for me in drush. The last bit of it had too high of an offset and was throwing an error even though it applied okay. Here's a new version with fixed line numbers.

jsagotsky’s picture

And just because draggable-329797-4.patch breaks tabledrag.js_8.patch, here's a version of tabledrag to apply after you've patched with draggable-329797-4.