<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Useful Qlikview Javascript for Chrome Ajax client in Member Articles</title>
    <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/ta-p/1682616</link>
    <description>&lt;P&gt;inspired by&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-Documents/Useful-Qlikview-Macros/ta-p/1494530" target="_self"&gt;Useful Qlikview Macros&lt;/A&gt;&lt;/P&gt;&lt;P&gt;These javascript code snippets can be used in the ajax client in Chrome. (not webview since that is IE and making things work in IE is painful)&lt;/P&gt;&lt;P&gt;All of these are wrapped in anonymous function that are immediately called, so they can be used in a button 'open URL' action in the same window like below so you don't have to install any extensions. You have to modify to code to do more things together for it to be useful since single actions can be done without any javascript coding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29718iD52C3299E0568060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1) Download a pivot table or straight table chart object as csv:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;LI-CODE lang="javascript"&gt;(function(){
    let convertObjectDataToCSV = function (data) {
        let result,columnDelimiter, lineDelimiter, strDataCell;
        columnDelimiter =  ',';
        lineDelimiter =  '\n';
        
        let wrapCSVCell = function(strCell){
            if( typeof strCell === "string") {
                    strCell = strCell.replace(/"/g, '""');
                    if (strCell.search(/("|,|\n)/g) &amp;gt;= 0){
                            strCell = '"' + strCell + '"';
                    }
            }
            return strCell;
        };
        
        result = '';
        result += data.HeaderRows.map(r =&amp;gt; r.map(c =&amp;gt; wrapCSVCell(c.text)).join(columnDelimiter)).join(lineDelimiter);
        result += lineDelimiter;
        result += data.Rows.map(r =&amp;gt; r.map(c =&amp;gt; wrapCSVCell(c.text)).join(columnDelimiter)).join(lineDelimiter);
        
        return result;
    };
    let saveAsCsv = function(filename, data) {
        let blob = new Blob([data], {type: 'text/csv'});
        let elem = window.document.createElement('a');
        elem.href = window.URL.createObjectURL(blob);
        elem.download = filename;        
        document.body.appendChild(elem);
        elem.click();
        window.URL.revokeObjectURL(elem.href);
        document.body.removeChild(elem);
    };

    let GetObject = function(doc,objectID){
        return new Promise(function(resolve){
            doc.GetObject(objectID,function(){
                this.DocumentMgr.RemoveFromManagers(this.ObjectMgr);
                this.DocumentMgr.RemoveFromMembers(this.ObjectMgr);
                resolve(this);
            });
        });
    };
    
    let GetObjectFullDataPage = async function (doc,objectID){
        let tableObj = await GetObject(doc,objectID);
        tableObj.Data.SetPagesize(tableObj.Data.TotalSize);
        return GetObject(doc,objectID);
    };
    
    let exportTableAsCSV = async function(doc, objectID, filename){
        saveAsCsv(filename,convertObjectDataToCSV((await GetObjectFullDataPage(doc,objectID)).Data));
    };

    exportTableAsCSV(Qv.GetCurrentDocument(),"CH01","export.csv");

}());&lt;/LI-CODE&gt;&lt;/LI-SPOILER&gt;</description>
    <pubDate>Wed, 21 Sep 2022 17:07:35 GMT</pubDate>
    <dc:creator>MikeW</dc:creator>
    <dc:date>2022-09-21T17:07:35Z</dc:date>
    <item>
      <title>Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/ta-p/1682616</link>
      <description>&lt;P&gt;inspired by&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-Documents/Useful-Qlikview-Macros/ta-p/1494530" target="_self"&gt;Useful Qlikview Macros&lt;/A&gt;&lt;/P&gt;&lt;P&gt;These javascript code snippets can be used in the ajax client in Chrome. (not webview since that is IE and making things work in IE is painful)&lt;/P&gt;&lt;P&gt;All of these are wrapped in anonymous function that are immediately called, so they can be used in a button 'open URL' action in the same window like below so you don't have to install any extensions. You have to modify to code to do more things together for it to be useful since single actions can be done without any javascript coding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29718iD52C3299E0568060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1) Download a pivot table or straight table chart object as csv:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;LI-CODE lang="javascript"&gt;(function(){
    let convertObjectDataToCSV = function (data) {
        let result,columnDelimiter, lineDelimiter, strDataCell;
        columnDelimiter =  ',';
        lineDelimiter =  '\n';
        
        let wrapCSVCell = function(strCell){
            if( typeof strCell === "string") {
                    strCell = strCell.replace(/"/g, '""');
                    if (strCell.search(/("|,|\n)/g) &amp;gt;= 0){
                            strCell = '"' + strCell + '"';
                    }
            }
            return strCell;
        };
        
        result = '';
        result += data.HeaderRows.map(r =&amp;gt; r.map(c =&amp;gt; wrapCSVCell(c.text)).join(columnDelimiter)).join(lineDelimiter);
        result += lineDelimiter;
        result += data.Rows.map(r =&amp;gt; r.map(c =&amp;gt; wrapCSVCell(c.text)).join(columnDelimiter)).join(lineDelimiter);
        
        return result;
    };
    let saveAsCsv = function(filename, data) {
        let blob = new Blob([data], {type: 'text/csv'});
        let elem = window.document.createElement('a');
        elem.href = window.URL.createObjectURL(blob);
        elem.download = filename;        
        document.body.appendChild(elem);
        elem.click();
        window.URL.revokeObjectURL(elem.href);
        document.body.removeChild(elem);
    };

    let GetObject = function(doc,objectID){
        return new Promise(function(resolve){
            doc.GetObject(objectID,function(){
                this.DocumentMgr.RemoveFromManagers(this.ObjectMgr);
                this.DocumentMgr.RemoveFromMembers(this.ObjectMgr);
                resolve(this);
            });
        });
    };
    
    let GetObjectFullDataPage = async function (doc,objectID){
        let tableObj = await GetObject(doc,objectID);
        tableObj.Data.SetPagesize(tableObj.Data.TotalSize);
        return GetObject(doc,objectID);
    };
    
    let exportTableAsCSV = async function(doc, objectID, filename){
        saveAsCsv(filename,convertObjectDataToCSV((await GetObjectFullDataPage(doc,objectID)).Data));
    };

    exportTableAsCSV(Qv.GetCurrentDocument(),"CH01","export.csv");

}());&lt;/LI-CODE&gt;&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 21 Sep 2022 17:07:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/ta-p/1682616</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2022-09-21T17:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1687142#M448</link>
      <description>&lt;P&gt;I tried your example for downloading a straight table chart object as csv, but it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error, when I click "Check" in the Edit Module:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Expected ';'" and it highlights the following:&lt;/P&gt;&lt;P&gt;let convertObjectDataToCSV = function (data) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;I want to have a macro button in my QlikView Application, so when the end user clicks on it from the Web View, then he gets a prompt to download a CSV extract of the straight table on any location he wants to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 23:05:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1687142#M448</guid>
      <dc:creator>Nissar</dc:creator>
      <dc:date>2020-03-23T23:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1687148#M449</link>
      <description>&lt;P&gt;It doesn't go into the edit module. You just put it in the url like in the screenshot.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 23:20:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1687148#M449</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2020-03-23T23:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768062#M450</link>
      <description>&lt;P&gt;I am having a hard time using this.&amp;nbsp; Could you please give an example of your code actually doing something?&amp;nbsp; like changing a font or exporting a table?&amp;nbsp; I hope to export a table to txt.&amp;nbsp; If I can get something simple to work... I think I can expand it, but I am stuck.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 22:46:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768062#M450</guid>
      <dc:creator>erikzions</dc:creator>
      <dc:date>2020-12-11T22:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768064#M451</link>
      <description>&lt;P&gt;I added an example qvw exporting a straight table to CSV. Use Chrome and Ajax client, not webview, to try it out. Let me know if it works for you.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 23:41:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768064#M451</guid>
      <dc:creator>MikeW</dc:creator>
      <dc:date>2020-12-11T23:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768353#M452</link>
      <description>&lt;P&gt;That is so cool!!! it is one step away from being a perfect solution for me.&amp;nbsp; Can it save the file to a folder instead of downloading to the download folder?&amp;nbsp; I don't want it to save to a file on the users machine... I want it to save to a file on the server.&amp;nbsp; This is awesome!!!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 19:02:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768353#M452</guid>
      <dc:creator>erikzions</dc:creator>
      <dc:date>2020-12-14T19:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768382#M453</link>
      <description>&lt;P&gt;I got it to work with a &lt;SPAN&gt;ServerSideExportEx&lt;/SPAN&gt;.&amp;nbsp; Thank you so much for your help!&amp;nbsp; This is cool stuff.&amp;nbsp; Kudos.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 20:19:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1768382#M453</guid>
      <dc:creator>erikzions</dc:creator>
      <dc:date>2020-12-14T20:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Useful Qlikview Javascript for Chrome Ajax client</title>
      <link>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1775517#M454</link>
      <description>&lt;P&gt;Hi, this is exactly what Im looking for! Thanks so much.&amp;nbsp; Do you have any idea on how to display a modal popup using this method?&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 10:36:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/Useful-Qlikview-Javascript-for-Chrome-Ajax-client/tac-p/1775517#M454</guid>
      <dc:creator>Senor_Dai</dc:creator>
      <dc:date>2021-01-19T10:36:31Z</dc:date>
    </item>
  </channel>
</rss>

