- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Tags:
- qlikview_extensions
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The "this" object in the callback function contains the object you're looking for. Use this.Data.Rows and it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is this correct var object = doc.GetObject(id); ?
it should be object = doc.GetObject(i); as you want traverse through individual objects.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey KStreak S,
thanks for your reply, but the data is still empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is it failing for last object ? what i suspect is when you start the loop from "Zero" you should use objects.length-1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That have I done now.
One other problem I have is, that my IE is frozen, perhaps there is a for(;;) loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The "this" object in the callback function contains the object you're looking for. Use this.Data.Rows and it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can try using the GetCurrentSelections function. The last parameter has the number of values displayed before qlikview shows x of y selected.
- « Previous Replies
-
- 1
- 2
- Next Replies »