Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Export Data from Mesh

Tried following the instructions but can't seem to get this to work.

I have a meshup and I want to add in the ability for end-users to export data.

Ideally, it would be for every object but at this point... I'll take what I can get.

For example below, I want to be able to export a pivot table from the meshup. But the HTML button / JS code doesn't seem to be working.

Any ideas? Thanks

JSCode.png

2 Replies
balabhaskarqlik

Try like this:

In the .js file I have the following function and this is being called everytime a user right-click on a container with the class "right-click-toolbar". Right-clicking on this container brings up a modal with some options. One of the option is the export data link:

    $( ".right-click-toolbar" ).contextmenu(function(event) { 

        event.preventDefault(); 

     

        var containerID = $(this).find("[data-qvobject]").attr('id'); 

         

        var qlikObjects = setObjects.toString(); 

        if(qlikObjects.indexOf(containerID) != -1){ 

            var tmpString = qlikObjects.substr(qlikObjects.indexOf(containerID), qlikObjects.length);  

            var ptrn = /(\d+|\w+|-_)/g; 

     

            var match, qlikID; 

            var test = ptrn.exec(tmpString); 

     

            if((match = ptrn.exec(tmpString)) != null){ 

                qlikID = match[0]; 

            }         

        } 

     

        $( ".export-data-link" ).attr({ 

            'qvdata-id': qlikID 

        }); 

    }); 

So what we do here is to find the id of the container that has the QV-object and attach that ID to the export link.

Next part of the the .js-file handles when the user clicks the export button:

    $( ".export-data-link" ).click(function(event) { 

        event.preventDefault(); 

     

        var qlikID = $(this).attr("qvdata-id"); 

     

        exportObject(qlikID); 

    }); 

     

    var exportObject = function(qvObj){ 

     

          app.getObject("export-container", qvObj).then(function(retObj){ 

     

              retObj.exportData( 'OOXML', '/qHyperCubeDef').then(function(c){ 

                  var d = "../.." + c.qUrl; 

                  $('.exportChart').attr({ 

                      'filename': "download", 

                    'download': true, 

                    'href': d 

                }); 

              }); 

          }); 

    }; 

The HTML looks like this:

    <div class="right-click-toolbar"> 

        <div id="QV01" class="qvobject" data-qvobject=""></div> 

    </div> 

Anonymous
Not applicable
Author

Hi Bala,

Not having much luck with that code either.

After I put in the javascript.. and add in the class "right-click-toolbar" ... nothing happens when I right click on the pivot table.

Are you able to send a basic html/js/css zip that contains a working example? Maybe I missed a spot.

Thanks !