Skip to content
This repository has been archived by the owner on Jul 25, 2021. It is now read-only.

Export table with data via JSON URL #55

Closed
rodrigoslayertech opened this issue Apr 25, 2017 · 3 comments
Closed

Export table with data via JSON URL #55

rodrigoslayertech opened this issue Apr 25, 2017 · 3 comments

Comments

@rodrigoslayertech
Copy link

rodrigoslayertech commented Apr 25, 2017

I am currently working with a table of over 1000 rows and 1000 columns. I am loading the rows of this table by JSON using the Bootstrap table extension: https://github.com/wenzhixin/bootstrap-table.
It's very hard for the browser to render the data from the HTML table and put it in the data-fileblob attribute every time I change the size of rows per page or refresh this huge table dynamically.
Is it possible to point table data via URL in settings to use remote JSON?

My Bootstrap Table Extension code:

    $table.bootstrapTable({
        url: '/result/data/',

        // Pagination
        pagination: true,
        pageSize: 100,
        pageList: [100, 500, 1000],
        sidePagination: 'server'

        // Toolbar
        toolbar: '#toolbar',
        showRefresh: true,
        showColumns: true,

        onLoadSuccess: function(data){
            // $table.tableExport.export(data); ?
            $("caption.btn-toolbar").remove();
            $table.tableExport({
                formats: ["xlsx"],
                position: "top"
            });
        }
    });

(Sorry my bad english. I'm brazilian)

@clarketm
Copy link
Owner

clarketm commented Apr 28, 2017

@slowaways - unfortunately, this is not possible with TableExport out-of-the-box. To be honest, TableExport, and client-side parsing, blobs, etc. in general, is not the most performant; it would be interesting to see benchmarks for a feature such as this after it is implemented.

Just to make sure I understand exactly what you are requesting, you basically want to, instead of parsing the table and saving the blob directly to the DOM element, have the ability to export to an external file and, when the user wants to export the table to xlsx, xls, csv, or txt, read the data from the external file?

As it stands, TableExport is a strict client-side library and I might have trouble justifying file writing from the browser. Better would be to use a Storage API like LocalStorage.

If we start talking server-side, with Node for example, this would be more than feasible, but then we would be talking about a separate release channel, with a whole set of additional dependencies.

Let me benchmark the potential performance improvements using some of the popular Storage APIs like LocalStorage, IndexedDB, etc. and see what sort of performance boost we can achieve. Would it be possible to share your source code or at least some of the raw data you are working with (at the very least - the unit size) so that I can get a realistic sample for testing?

@rodrigoslayertech
Copy link
Author

rodrigoslayertech commented Apr 28, 2017

"... read the data from the external file?"
Yes

There are currently 1116 rows and 1031 columns. My JSON data contain sensitive data of users as passwords, identity documents number, etc. and are data of research scientific. I can't share it.

I replace your library for another called DataTables because is more faster to export:
https://datatables.net/extensions/buttons/examples/styling/bootstrap.html

@clarketm
Copy link
Owner

clarketm commented Apr 28, 2017

Thanks for the quick response and detailed explanation. DataTables is a good full-featured library, and perfect for your use-case. But with 31,000+ lines of code in its most succinct distribution, it's difficult to say it's efficient for smaller projects. Compared to TableExport, with a mere 500 lines unminified (including descrptive comments, structural whitespace, and compendious JSDoc documentation), it's targeted for more modern, agile, and dynamic applications (well, at least that was my original inspiration for the library :)) For future reference, research the concept of obfuscation which can help with sharing the context of an issue/problem without leaking sensitive data.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants