Displaying large data sets/tables - DataTables boilerplate

This is a Shortcut for helping people display large amounts of data. It doesn’t do anything practical, its a starting point for creating your own easy to use on mobile tables.

It uses DataTables to show tables in a way that works better for mobile, with pagination, search, responsive tables, and will bunch data with expand/collapse to make it easier to work with on mobiles.

It contains a sample table, which you should fill the text action with your table, or the output of your Shortcut in table format. You could use this Shortcut as a starting point for eg a CSV to tables Shortcut, or to pick up saved CSV in your iCloud Drive you need to view etc.

For a more advanced user, you could also insert the data as javascript data rather than go through the extra step of generating tables. That isn’t covered here more information : https://datatables.net/manual/data/

I’d love to hear if anyone uses it in a project.

Automatically reforms to Landscape or Portrait. With hidden details available in portrait via expand/collapse buttons

3 Likes

This looks seriously awesome, may replace Filemaker Go for me for some applications. FM makes it very expensive to sync as a single user, so I’ve been using my databases read only on iOS anyway.

The example here just converts a html table of data.

You’ll probably want to look at the JavaScript var method as it’ll be easier than trying to convert any data to a table first.

Someone on Reddit mentioned they used this https://github.com/derekeder/csv-to-html-table as well which apparently makes easier to send csv to DataTables but I have no personal experience of it so cant say if its any good myself.

1 Like

Yes, I see now that I’m on iOS — I’ll need to look into converting CSV to html. I already have a csv parser, so it shouldn’t be too bad.

Here’s a quickly hacked together shortcut that uses viticci@macstories.net Spreadsheet to Markdown which takes a Clipboard Copy of spreadsheet data converts it to Markdown table, then html then adds it into the boilerplate.

Still not as neat as adding in the csv directly as JavaScript variables/arrays, but might give you some ideas https://www.icloud.com/shortcuts/fd83c98e588b4b60a0ce9dabe1d40aa6

Article : https://www.macstories.net/ios/workflow-convert-spreadsheets-to-multimarkdown-tables/

1 Like

Well I ended up adapting my parser but it’s way too slow - I think I’d need to do the conversion to html in advance and cache it or keep the file on a server somewhere and let it handle the conversion. Talking 12-25 seconds for a table with 80 rows and maybe 100 columns.

Here’s the parser - it expects a CSV file as input.

https://www.icloud.com/shortcuts/20088d202df64c6bab4e7483eb32fadd

(Updated to fix a sloppy html error on my part)

And the version of DataTables which it calls, expects a html table as input, minus opening and closing table tags:

https://www.icloud.com/shortcuts/b18c8935167b4582bbc87c4f1b6b67e9

1 Like

It’s quite possible I will update it to deal with csv directly, I just don’t want to commit to saying I will as I have more urgent demands on my time right now.

Honestly unless you’re going to build it in another language and integrate it, I wouldn’t invest the time, Shortcuts is natively too slow to do long iterations.

I think it will be most useful for saving the results as bookmarks, where you run the Shortcut once to create the page. I’d also be more interested in seeing tweaks to the UI to add buttons e.g. to copy a result etc.

Do you have an idea why my parser and version don’t produce the search box or column sort buttons?

Javascript variable/arrays are something like var = { “sdfsf”,“sfsdfa”,“sdfs” } so appears easy to reformat and insert, might be a few gotchas around escaped characters and obscure csv formats but not too hard.

With simple csv https://routinehub.co/shortcut/981

1 Like

@entee thanks for sharing! Very useful. I’ve converted a few of my “display info” type Shortcuts to use a DataTable view. Far more flexible and visually appealing than a QuickLook or Show Results.

1 Like

This is clearly parsing csv much faster than the approach I had taken - looks like you are using replace in the text rather than parsing out each delimited item - nice.

@entee again… really enjoying having this capability. I’ve been exploring the DataTable API (first time I’ve used it). I would like to enable the horizontal scroll using the scrollX attribute.

This attribute doesn’t seem to change the behavior. If I set to true, the columns displayed doesn’t change. I still have the expand/contract button to see the overflow columns. I would like to simply have all columns scrollable.

Thoughts on why the scrollX attribute may not be working?

Other parameter changes are working (eg, paging: false)

Thanks for any tips…

I had hoped not to have much parsing going on at all, but glad to know the Search/Replace on , with “,” works a bit faster.

Seems to work ok when I enable it, it only shows 2 columns on my phone landscacpe when enabled. Could you share the $( '#example' ).dataTable( { bit with all the options you have. enabled.

Here’s a snippet from the Text action

];

$(document).ready(function() {
$(’#example’).DataTable( {
responsive: true,
paging: false,
ordering: false,
scrollX: true,
searching: true,
info: true,
data: dataSet,

Sorry not sure what’s causing the issue.

To circle back on this… setting responsive to false enabled the behavior I was seeking. That is, full view of all columns of data

Thanks for the update.