Hi all,
I was test driving this module and I think I have good use for it in my site. I like the features it offers, but before I commit to making it part of my site, I would like to pose these questions please ...

1- What are the future plans for this module? Is still being developed?
2- I got hit by the column deletion bug. This is major for me since it will be near impossible to recreate tables to simply delete a column specially if these tables become populated with 1000s os rows. Unless I missed something ...
- this bug has not been fixed so far, are you planning to address it in future releases and when?
- How to do you work around it for existing tables that have 100s or 1000s or rows?
3- Does these module have a feature that allows users to search a table created by it or may be a a filter? I did see that you can do filters, but how to you get it exposed to the user?
If not possible, how do you do that?

Comments

pobster’s picture

Hiya,

In answer to your questions;

1. Yes it's currently being developed (or was being until recently when I got busy doing paid stuff which obviously takes precedence!) The current version has hit a bit of a wall, but it's one I can get round when I have more time to spare.
2. You've not got hit by a bug - you just can't delete a column - no-one can, a change to Drupal core broke the module and tbh, that function could do with a complete rewrite. However... I don't see much point in rewriting it as any spare time I have will obviously be better spent on finishing Tablemanager V2, especially as this issue has already been fixed in a hack-ish way here; http://drupal.org/node/77604 As for 'how do I work around it'? I really don't understand what you mean? Get round what? It's just a broken link to a function, it makes no difference whether you've 1 table entry or 1 million.
3. This version doesn't, the new version does. If you've embedded the tables in nodes then the Drupal search will work and return matches.

Just to clarify, the new version creates tables as nodes and so negates the need to embed anything. You can then either use the same tablemanager list screen to list the tables you have, else I've written a views compatible module which does the same thing (actually I might just do away with the modules own table list screen, I think I'd prefer to rely on the views module?) The new table add screen allows you to set separate table attributes for each table (eg. alignment, width, cellpadding, cellspacing, border, frames+rules, styles attributes like bgcolor and classes for theming) using a ui rather than a long strung out filter tag. The new module uses pluggable fieldtypes as well, so there's no need to update the core tablemanager module to have new fieldtypes.

...Meh there's probably other stuff as well, I forget...

Thanks,

Pobster

cnewtonne’s picture

Thank you for taking the time out of your super busy schedule to address my issues. I'm good on most of the reply except the column deletion issue on existing tables. Can you please explain to me how to go about handling this situation...

I created a table with 2500 rows in this module. Few days later, I wanted to delete 3 columns. I attempted to blank out the column lables, but it did not do it. What I saw so far is the recommendation to recreate the table. If you do that ...
- isn't deleting this table will delete its data as well.
- If I save the data, delete the current table and recreate it. I take it I can use the import from csv feature to populate it. Correct? am I missing anything here?

- I read the 'hackish' way you pointed to before, you are saying ...
....
Anyway, as a short-term fix, if we intercept the the $op="Delete" operation early in the _tableedit(...) function, and then forward to _columndelete_submit(...), the column is deleted as desired. Crude, but I don't have time to figure out a more elegant fix
...

How do you go about 'intercepting such operation'?

pobster’s picture

Status: Active » Closed (fixed)

I reiterate; I have no interest in fixing the column delete function - it's not a simple fix, the hack-ish way will work, but it's not a sensible or 'clean' fix and that function really should be rewritten to cope with the new (well not new any more) forms API usage of tokens.

The new version of the module already has column delete functioning, but it works in such a different way that it's pointless backporting it (old tables need to be run through an upgrade script to become compatible with the new version - it's *that* different).

The actual column delete function works just fine, it's only the link to it which is broken. You could always just enable the devel module and use this snippet to delete your column; (or perhaps create a node and use the php input filter - then just 'preview' to run through the function once)

  $col = 1; // obviously change this to reflect your column
  $edit = 1; // and this to reflect the table id
  $row = array();
  $fetch = db_fetch_object(db_query('SELECT tm.header
                                     FROM {tablemanager} tm
                                     WHERE tm.tid = %d',
                                     $edit));
  $header = unserialize($fetch->header);
  if (array_key_exists('sort', $header[($col-1)])) {
    $oops = "Please be aware that this column was the default for sorting.";
  }
  array_splice($header, $col-1, 1);
  for ($i = 0; $i <= count($header); $i++) {
    if (is_array($header[$i]) && array_key_exists('field', $header[$i])) {
      $header[$i]['field'] = $i+1;
    }
  }
  db_query("UPDATE {tablemanager} SET header='%s' WHERE tid='%d'", serialize($header), $edit);
  $sql = db_query('SELECT tmd.id, tmd.data
                   FROM {tablemanager_data} tmd
                   WHERE tmd.tid = %d',
                   $edit);
  while ($fetch = db_fetch_object($sql)) {
    $id = $fetch->id;
    $row = unserialize($fetch->data);
    array_splice($row, $col-1, 1);
    db_query("UPDATE {tablemanager_data} SET data='%s' WHERE id='%d'", serialize($row), $id);
  }
  drupal_set_message(t("Column '%col' in table '%table' has been deleted.", array('%col' => $col, '%table' => $edit)));
  if ($oops) {
    drupal_set_message(t('%oops', array('%oops' => $oops)), 'error');
  }
  watchdog('tablemanager', t("tablemanager: deleted column '%col' in table '%table'.", array('%col' => $col, '%table' => $edit)), WATCHDOG_NOTICE, l('view', 'tablemanager/'.$edit));
  drupal_goto('admin/content/tablemanager');
  return;

Pobster