nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.36k stars 1.08k forks source link

Export with data load from an HTML table #755

Open ruimparente opened 7 years ago

ruimparente commented 7 years ago

Hello Nicholas,

I am pretty new to JavaScript and i'm using your component for an application i'm working on. I'm getting the data for the Pivot Table from an HTML table and i want to add the Export option but i'm getting problems adapting the code from a Json input to an HTML input. The code i'm using is the following:

       <script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.13.0/pivot.min.js'></script>
        <script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js'></script>
        <script src='https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.13.0/export_renderers.min.js'></script>
        <script> 
        $(function(){
        var renderers = $.extend($.pivotUtilities.renderers, $.pivotUtilities.export_renderers);
        $('#" + PivotTable.Id + "').pivotUI($('#" + LastDiagnosisTBL.Id + "',{
            renderers: renderers,
            rows: ['Nationality', 'Gender'],
            cols: ['Diagnosis'],
            rendererName: 'Export'
        }));
     });</script>

Could you help me finding what's wrong with it?

Thanks and keep up the good work.

Rui

nicolaskruchten commented 7 years ago

The renderer name is not 'Export' but 'TSV Export' ...

ruimparente commented 7 years ago

I made that change but it still isn't working. What happens is that the output table is being rendered but it comes out empty.

nicolaskruchten commented 7 years ago

Hmmm. Unfortunately you'll have to give me a JSFiddle or something as this isn't enough to go on, sorry :)