Thanks for the module saved me from a headache,
would just like to know if there is a way to calculate the values of columns and displaying them at the bottom like a excell sheet...
or use the default fields as tokens
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | tablefield_calc.png | 97.1 KB | jonathan_hunt |
Comments
Comment #1
jonathan_hunt commentedI've been hacking on Tablefield to (a) assign spreadsheet-like cell references, (b) mark specific cells as headers (readonly) and (c) support simple formulas (refer to the screenshot below). I've done this by hacking the tablefield_process() function to support the special default cell values and attach additional attributes, output javascript code, etc. I can make this available as a patch if there is interest.
Comment #2
tonyda345 commentedI am interested. Can you make this patch available?
Comment #3
jonathan_hunt commentedSorry for the delay. Unfortunately making it available as a patch is problematic because I'm also apply a bunch of other patches to this module and it's not easy to separate out the code for this. In any case it would good to get more input regarding how best to augment TableField to have this capability; perhaps some kind of render hook.
In tablefield.module, I added the following. This only handles the simplest case: A1+B1+C2 for example.
There's no out-of-range checking etc. at this point. What we really need is perhaps to eval in js for a limited set of operators.
The tablefield_process() function has been rewritten to output spreadsheet-style cell identifiers in the cell class (e.g. A1, B2 etc.) Also, I've introduced a notation of *header* to process the cell as th instead of td. If the render detects = it assumes a formula and outputs javascript.
This suits my current use case so I don't expect to do much more with it but it would be nice to have this capability included in the module, or for the module to provide some extension points to make this modification easy in a separate module.
Comment #4
spineless commentedI am using tablefield version 7.x-2.0-beta4.
I added the two code snippets you posted and I did not get any errors. :)
How do I use the code to add up a column of data? Ie a2+a3+a4
How do I call the function?
There looks like there might be an element or two missing in your code snippet in order to implement the function. Can you give me a rundown how you implemented to code?
Thanks,
spineless
Comment #5
lolandese commentedTake a look at https://www.drupal.org/project/sheetnode. Out of scope for this module.