Qlik Community

QlikView Extensions

Discussion Board for collaboration on QlikView Extensions.

Not applicable

Reading the current selection, data is empty

Hey,

I want to have access to the selected values: I want to do this with an click-Event: Go through every element, look at the Current Selection Box and read the data in there.

var doc;

function getObjectList() {

    doc = Qv.GetCurrentDocument();

    doc.GetAllObjects(function (objects) {

          for (var i = 0; i < objects.length; i++) {

              var obj = objects;

              var id = obj.id;

              var caption = obj.caption;

              var type = obj.type;

              var my = obj.my;

            console.log("[obj:" + obj + " id:" + id + " caption:" + caption + " type:" + type + " my: " + my + "]");

            if (type === "Statusbox") {

                var object = doc.GetObject(id);

                //object data is empty, why is this empty, I have some data in there

                var dataContent = objekt.Data.Rows;

               

                    for (var i = 0; i < dataContent.length; i++) {

                        var content = dataContent;

                        console.log("Name: " + content[0].text + " Value: " + content[2].text + " Optional: " + content[1].text);

                    }

           }

       }

    }

    )};

Do you have some idea?

1 Solution

Accepted Solutions
Highlighted
Not applicable

Re: Reading the current selection, data is empty

The "this" object in the callback function contains the object you're looking for. Use this.Data.Rows and it should work.

10 Replies
Not applicable

Re: Reading the current selection, data is empty

is this correct var object = doc.GetObject(id); ?

it should be object = doc.GetObject(i); as you want traverse through individual objects.


Not applicable

Re: Reading the current selection, data is empty

Hey KStreak S,

thanks for your reply, but the data is still empty.

Not applicable

Re: Reading the current selection, data is empty

is it failing for last object ? what i suspect is when you start the loop from "Zero" you should use objects.length-1

Not applicable

Re: Reading the current selection, data is empty

That have I done now.

One other problem I have is, that my IE is frozen, perhaps there is a for(;Smiley Wink loop

Not applicable

Re: Reading the current selection, data is empty

Qv.Document.GetObject actually takes two parameters. The first parameter is the object id, the second parameter is the function callback when the object is rendered  (the second parameter is missing from the argument list in the documentation). The object returned by the GetObject call may or may not have data; it depends on if the object has already been drawn.

Not applicable

Re: Reading the current selection, data is empty

Do you mean something like that:

if (type === "Statusbox") {

   doc.GetObject(id, function (statusbox) {

   var statusboxInhalt = statusbox.Data.Rows;

         for (var i = 0; i < statusboxInhalt.length; i++) {

               var inhalt = statusboxInhalt;

               console.log("Name: " + inhalt[0].text + " Wert: " + inhalt[2].text + " Optional: " + inhalt[1].text);

          }

      });

}

Or I am wrong, can you give me some codesnippet.

Highlighted
Not applicable

Re: Reading the current selection, data is empty

The "this" object in the callback function contains the object you're looking for. Use this.Data.Rows and it should work.

Not applicable

Re: Reading the current selection, data is empty

Thank you vhuynh, your solution is working:

But know I have a other problem, I want to see every single field this is selected. But for example, when I take many distinct values, then there are the text shows for example 18 of 80 selected, but I want every single value.

Could this be solved?

Not applicable

Re: Reading the current selection, data is empty

You can try using the GetCurrentSelections function. The last parameter has the number of values displayed before qlikview shows x of y selected.