Link the button to a qlik js extension functionality

I am currently working on developing a JS extension for Qlik Sense and my goal is to create an extract button similar to the one provided in the documentation.

I have two options to achieve this - one using AngularJS and the other using jQuery + JS.

First Approach: I attempted to use AngularJS:

html = "<div class='exportArea' style='float:right'><div id='exportText'></div><button ng-click=\"table.exportData({download:true})\">Create Excel file</button></div>" + html;

Unfortunately, I did not succeed with this approach.

Second Approach:

Next, I tried using $element.find.

$element.find("#exportButton").on("qv-activate", function(){}

However, I was unsure of how to proceed with calling the export function afterwards.

var qTable = qlik.table(this);

var $exportButton = $( document.createElement('button'));
$exportButton.html('Export');
$exportButton.bind('click', function (  ) {
            qTable.exportData({download: true});
        });
$element.append($exportButton);

In summary, my ultimate goal is to integrate the code from the documentation using the tag id='exportButton' within the existing structure.

html = "<div class='exportArea' style='float:right'><div id='exportText'></div><button id='exportButton'>Create Excel file</button></div>" + html;

Thank you for any assistance in advance!

Answer №1

For your initial method:

You must establish the table within the scope either in the Paint function as shown below:


paint: function ( ) {
    // ...
    if ( !this.$scope.table ) {
        this.$scope.table = qlik.table(this);
    }
}

Alternatively, you can define it in the Angular controller like so:

controller: ['$scope', function ($scope) {
    $scope.table = qlik.table(this);
}]

In the second approach, $element refers to the HTML element where the button will be appended. You can utilize this added button or select an element using a function such as getElementById (likely not on the document but rather on the extensionContainer):

paint: function ($element, layout) {
    $element.getElementById('exportButton').onlick=()=>{
        qlik.table(this).exportData({download: true});
    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Starting service upon startup in Angularjs

I am looking to retrieve configuration data from the server and store it in the global scope within my AngularJS application. My app operates in multiple modes such as development and production, with different external services being used depending on the ...

When using JSON.parse, it may sometimes return [Object Object] instead of the expected

The JSON output of my API looks like this: [{"UserName":"xxx","Rolename":"yyy"}] I am trying to extract the values for Username and RoleName separately using JSON.parse, but it is giving me [Object Object]. Can someone please assist? Your help is much ap ...

Transferring webpage code through JSON from PHP to JavaScript

I am using the jquery_form plugin to send an HTML form to PHP, which then sends back a JSON object. Here is what PHP sends back: $content = "<div>ABC</div>"; $json = json_encode(array("content" => $content)); // Here I also send $json to M ...

The Node.js application is up and running on the Node server, but unfortunately, no output is

Greetings, I am a beginner in nodejs. var io = require('socket.io').listen(server); users = []; connections = []; server.listen(process.env.PORT || 3000); console.log('server running....on Pro'); app.get ('/', function(re ...

Utilizing "Content" for Responsive Image Design in Chrome Version 33.0.1750.117

I previously implemented a method for responsive images on my website, which was working fine until the latest Chrome update. Surprisingly, it still functions properly on other browsers. //< ![CDATA[ var queries = [ ...

Utilizing Chrome's developer tools to incorporate Angular directives

I am currently dealing with a collision between two libraries in my code and I am working on debugging where the issue lies. To make this process easier, I have been attempting to modify the HTML directly using developer tools and see the immediate effec ...

Retrieving data from a cell within an HTML table by utilizing the children[] method

I've been trying to extract a specific value from the HTML of a cell in an HTML table. I attempted to use the .rows parameter initially, but that resulted in the JavaScript halting at the line involving .row. Currently, I have resorted to assigning an ...

Checking if an item is present in a list using Angular's ng-checked

I have a challenge with two lists of items: all_todos my_todos My goal is to develop a directive that can automatically update the checkboxes of the todos based on changes in the my_todos list anywhere else within the application. <tr ng-repeat="todo ...

Implementing a method to display HTML tags within text in a React application

I have been working on a text highlighting feature, and I have successfully detected the selection. Currently, I have something like Te<span>x</span>t within a string, represented as an array: ["Te", "<span>", "x ...

What is the right way to utilize Fetch in JavaScript and Django?

I am currently working on creating a METAR decoder similar to the one shown in this image: https://i.stack.imgur.com/P40uG.png For this project, I am implementing the use of the fetch function in Vanilla JavaScript. The goal is to send the inputted code t ...

Is there a way to avoid adding this final "faulty state" to the array?

While working on dynamically slicing an array, I noticed that my while loop was causing an extra slice to be added when it broke the conditional. Even though I can achieve the desired functionality by removing the last element with arr.pop(), I am curious ...

VeeValidate fails to validate input fields in a form that is constantly changing

My goal is to create dynamic forms with validations using veeValidate in Vue.js. I am attempting to achieve this by storing an array of objects within the component's data. For instance: data(){ return{ inputs: [ { id: 1, lab ...

Running the AngularJS documentation on a local server

I recently downloaded the latest version of angular.js and noticed that all the links in the documentation lead to absolute URLs like angularjs.org/.... I would like to find a way to access and read the documentation offline. ...

Tips on capturing JSON data for export and sending it to a specific URL

After implementing the recommended code changes, I still cannot see any updates on the specified WordPress page - . It appears that there may be a login information or other issue preventing me from viewing the changes. Here is the updated code: // New ...

Optimal scenarios for utilizing $eval and $parse functions

Exploring the applications of $eval and $parse in AngularJS. eReaderBook.controller("mainCtrl",function($scope){ $scope.test = "asdasd"; var s = "{{test}}"; console.log($scope.$eval("s")) }) Understanding why the console.log statement returns ...

Disable the 'scroll up' script for mobile devices

I am using the code below in my < head > tags to create a button that fades in when the window is 150px from the bottom. <script> $(window).scroll(function () { if ($(window).scrollTop() + $(window).height() > ($(document).height() - 150) ...

How can you retrieve the current server time within the MEAN stack (MongoDB, Express, Angular, Node)?

SCRIPT: exports.generate = function (req, res) { var note = new Note(req.body); note.author = req.author; console.log("1) PREVIOUS: "+note.author.prev.getTime()); console.log("Server Time is: "+getServerTime()); if (note.author.prev != null &a ...

Leveraging the Power of jsPDF in Your Google Apps Scripts

Is it feasible to integrate jsPDF into a Google Apps Script project? I am attempting to create documents using templated HTML, but certain CSS styles like background-color do not translate to PDF when using the getAs() function. Given the limitations of ...

When using the keyboard to navigate, the aria-label attribute is not being properly recognized

<span class="phone" aria-label="phone number 9 4 9 . 5 5 5 . 1 2 3 4">949.555.1234</span> This code snippet displays a phone number on the webpage. When clicking on the phone number, it reads the aria-label as intended. However, if you navigat ...

What is the best way to compare the lengths of all nested child elements with each other?

I have an object with nested children, like this: $scope.artists.materials.items[] //contains list of items Now I need to compare the total length of each artist's list of items. If there is a mismatch in the number of items between artists, I want ...