I want users to see modified HTML content (where applicable) and let them copy/save the table contents as csv in their a raw “stringified” form.
Something like this:
- Original data:
[{name: 'Timmy', url: '#timmy'},{name: 'Jimmy', url: '#jimmy'}]
- Cell text:
Timmy, Jimmy
- Rendered Cell:
<a href="#timmy">Timmy</a>, <a href="#jimmy">Jimmy</a>
How I’ve planned it this far:
-
http://jsfiddle.net/7a9boje3/ - The cells in the second column use a static object as a placeholder in the renderer (line 89) and is therefore just showing duplicate placeholder content at the moment.
-
If I do nothing to modify the original array contents, every cell of the second column would look something like this:
[object Object],[object Object]
. You can see what that would look like by uncommenting line 35 and commenting line 36. -
So I figured that I could “stringify” the column data (line 28) and that seems to work up to this point. Users will see something like:
Timmy, Jimmy
and that is also what they get when they copy the cell contents. You can see what that looks like by commenting out the renderer at line 36 (and make sure line 35 is also commented). -
Then the plan was to add a custom renderer to generate HTML in its place, something like:
<a href="#timmy">Timmy</a>, <a href="#jimmy">Jimmy</a>
(lines 36 and 83). Custom renderer would make it work exactly as I wanted, but since I stringified the column data in the previous step, I can’t fetch all the properties I need to generate the HTML exactly as planned. I can only access the source data as a string and not in its original form, which makes it kind of difficult to then fetch the url or any other properties it may have. And again as a reminder, the renderer is currently using the same static placeholder object for all rows (line 89) just to show how I would generate the HTML if I could access the original array of objects.I tried a bunch of different ways to get the source data and whatnot (line 94), but it’s just giving me the stringified data.
If I didn’t edit the column data at all (line 28) I could access the data in the renderer using
instance.getSourceDataAtRow(row).people
, but then you can’t copy or save the CSV with the cell contents in a stringified format…
Any ideas on how to get past this hurdle?