Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I'm trying to retrieve the current selections in my extension.
I tried the example from QlikView Ajax JavaScript Library but when I select more than 6 values, I get a result in the form "x of y".
Could anyone please help me? Is there a method like the GetFieldSelections in desktop API?
Andrea
Hi
Lets try this then (inspired by Steoel above)...
Define an "invisible" text property in the Define.xml file:
<Text Expression="=GetCurrentSelections('',':',',',100)"/>
Make it invisible by not supplying any code for this Text input in the .qvpp file.
Then, in JavaScript, read the value of the corresponding text field:
currentSelections = this.Layout.Text##.text;
where ## is the corresponding text number (0 for the first Text in the Definition.xml, 1 for the next and so on).
I use this technique to get the current QlikView version (<Text Expression="=QlikViewVersion()"/>) and it works fine, so this should probably work as well.
Br Patrik
You can add a parameter to the getcurrentselection function to make it return more values: GetCurrentSelections('',':',',',100). The default is 6, in the example this is set to 100.
Hi,
GetCurrentSelections('',':',',',100) works correctly in QlikView desktop but I need to get current selections from within my extension (from java script).
I tried the following example that you can find in the QlikView Ajax JavaScript Library but it works as I wrote: The red higlighted row returns "x of y".
Any suggestions?
Thanks.
Hi Andrea
I haven't used this method, so I do not know. But have you looked through the other elements in the array? Element 1 and possible elements 3, 4 or more (if they exists). And are there other properties part from .text that could give what you are looking for?
As you probably are aware of, the documentation of these things are not living up to the standards one would wish for.
Br Patrik
Hi Patrik,
Unfortunately Element 1, 3, 4, etc... retrieve "undefined" result.
Hi
Now I got curious and tested the code from JsDoc and it worked fine in my test.
I put this code in a Script.js file (in the global namespace):
Qv.GetCurrentDocument().GetCurrentSelections({
onChange: function () {
var f, data = this.Data.Rows;
for (f = 0; f < data.length; f++) {
alert(data
}
}
});
And I got alerts for all selections of all fields.
What version of QV are you using? I'm running 11 SR2.
Br Patrik
The code you posted is the same that I tried and it works.
But if you select more than 5-6 values for a specific field, data
Try your code with a lot of selections and let me know if it works.
I'm using 11 SR2 too.
Hi
Sorry, read to quick. Yes, I get the same response too. And the same when running the plugin as well. I think this is delivered from the server and I have not been able to find any setting for this (part from the VBScript/JScript API reffered above).
In the documentation there is a reference to a Qv.FieldOptions and there some fields indicate some kind of size setting, but passing the fields does not work. I looked into the JavaScript for GetCurrentSelections and CurrentSelectionMgr and it looks like the fields data is never used.
I guess that one way to solve this is to read data from a listbox as soon as there are more than 6 values selected.
Br Patrik
Hey,
there is one workaround to solve your problem: The API from QlikView I think is a little bit buggy. So, first define a
Textbox object. In this object you can write an expression, something like this:
=GetCurrentSelections('',':',',',100)
Now you have the CurrentSelection in an defined object;
next you must read via the JS-API the object data out;
doc.GetObject("OBJECTID", function () {
//then you must split the string you get by the signs you have defined
...
}
This is some solution to solve the problem.
Thanks,
We have already tried that but we want to avoid using a specific graphic object in the qvw.