I've created the code and some pages for a Drupal 7 tabledrag demo. The demo site is here.
Please use the "Contact Carl" main menu option on the site if you have any questions or comments.

Comments

RikD’s picture

Hi,

Thank you for this nice example, already searching for a long time to get a good example. I only have one problem.

I only see the weight column and nothing more. I'm using the same code as in your example. I've changed "type => textfield" to "type => weight", but this didn't causes the problem I've tried both.

Do you have any idea how I can solve this problem?

Thanks,
Rik

carlwenrich’s picture

See user_admin_roles for an example from the Drupal 7 core. If you change it to "weight" you'll get a select box that becomes unwieldy when you have a large number of entries.

If you change anything in the theming, install the devel module and click the "Empty cache" link to update the theme registration.

Of course it goes without saying that you need all five parts:

  1. function tabledrag_schema()
  2. function tabledrag_demo_form($form, &$form_state)
  3. function tabledrag_demo_form_submit($form, &$form_state)
  4. function theme_tabledrag_demo_form($variables)
  5. function tabledrag_theme()
RikD’s picture

Hi,

Thanks for your reply, got it working. I had some naming conflicts, but it is all working now.

I only had one small issue. When I click "Show row weights" the row weights show as it should be, but I can't set it back to dragging. Somehow the "Hide row weights" doesn't work. When I hit the save button it will go back to dragging. But atm this isn't a big issue for me

Thanks,
Rik

carlwenrich’s picture

Go to Structure > Menus > Main menu > list links.
Click "Show row weights" there and see if you have the same problem.

RikD’s picture

Sorry for the late reply.

The problem has been solved, it was happening on a drupal 7.2 installation (My own table as well as the menu table). On drupal 7.9 it seems to be resolved.

carlwenrich’s picture

Each function is now fully documented, and the code has been simplified.
The site is here.

carlwenrich’s picture

The "edit" and "delete" operations have been added to the tabledrag demo.
The site is here.

SimonMartineau’s picture

Hello,

I'm am very interested about your example but it's impossible to access to the website. Can you post it again somewhere?

Thanks

Simon