1 Reply Latest reply: Oct 29, 2014 1:16 PM by Lee Matthews RSS

    Function in Mashup to Clear All Selections

    Lee Matthews

      I have a custom webpage on an IIS server with some mashup content plugged in. It is working fine. I need to add a button to allow the user to clear selections. The mashup API has a method called clearAll() here which I should be able to use. However I am not sure how to implement this. The javascript file associated with my mashup is attached. an extract is below.


      - I can see that the connection to the app is defined in the first block of code.

      - When I reference the app object in the second block it does not work

      - I am guessing the second function needs to somehow be embedded into the first block, is that correct?

      - I dont quite understand the requireJS syntax, so I am a little lost on h


       

      require( ["js/qlik"], function ( qlik ) {

        qlik.setOnError( function ( error ) {

        alert( error.message );

        } );

        //callbacks

        //open app and get objects

        var app = qlik.openApp("Thread Bare Clothing Sales.qvf", config);

        $(".qvobject").each(function() {

        var qvid = $(this).data("qvid");

        app.getObject(this, qvid);

        });

        /*AUTOGEN START*/

        /*AUTOGEN END*/

      } );

       

       

      function clearAll(){

        alert("start")

        app = qlik.currApp();

        app.clearAll();

        alert("end")

      }

        • Re: Function in Mashup to Clear All Selections
          Lee Matthews

          To anyone interested in the solution, one of my (very) esteemed colleagues suggested the following approach which worked perfectly.


          Add this to your HTML

          <div id="ClearAll"><button>Click me</button></div>

           

           

          And then add to the JavaScript what it should do when clicked (below in Red)

          var config = {

                host: window.location.hostname,

                prefix: "/",

                port: window.location.port,

                isSecure: window.location.protocol === "https:"

          };


          require.config( {

                baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port: "") + config.prefix + "resources"

          } );

           

          require( ["js/qlik"], function ( qlik ) {

                qlik.setOnError( function ( error ) {

          alert( error.message );

                } );

           

                //callbacks

                //open app and get objects

                var app = qlik.openApp("Barcelona Basecamp.qvf", config);

          $(".qvobject").each(function() {

          var qvid = $(this).data("qvid");

          app.getObject(this, qvid);

                });

           

                $("#ClearAll").click(function() {

          app.clearAll();

                });

               

          /*AUTOGEN START*/

          /*AUTOGEN END*/

           

          } )