If you want to use the multiselect in scorecard, this blog is for you.
The way to do
In scorecard, when selection type is "Multi", then you are allowed to chose more rows at one time (CTRL, SHIFT buttons work then). The information will be passed to the scripting, there you can use "getSelection()" method to read it out.
The implementation
Using script, the method is giving you for every dimension all selected members (in case you use CTRL only one is given, by SHIFT more than one).
The restriction
The API is giving you the dimensions INDEPENDENTLY, therefore the multi selection is basically working only when you have only one dimension in your row scope.
Why? Via the current API it is not possible to readout the dependencies between members of more than one dimension.
How you can read it out?
/assumption: only one dimension in row scope/ then the selection is toggled and can be on or off. You need one global variable on in scripting as you need to make a code which works like a semafor:
* global variable does not have a member -> selection
* global variable already has the member -> de-selection.
Script
var
colSel = SCORECARD_1DIM.getSelectedColumnId();
var sel = SCORECARD_1DIM.getSelection();
sel.forEach(function(value, key) {
if(key == "Product" && SELECTION_Product == "") {
SELECTION_Product = key + "|;";
}
value.forEach(function(element, index) {
if(key == "Product") {
if(SELECTION_Product.indexOf(";" + element + ";") > -1) {
// the element is now unselected!
SELECTION_Product =
SELECTION_Product.substring(
0,
SELECTION_Product.indexOf(element + ";"))
+
SELECTION_Product.substring(
SELECTION_Product.indexOf(element + ";") + (element + ";").length
);
} else {
SELECTION_Product = SELECTION_Product + element + ";";
}
}
});
});
TEXT_2.setText(SELECTION_Product);
asas
As you can see, there is a simple check and modification of the selection string.
I use the ";" character in the beginning to avoid that the IF check in line 12 will be positive in case there is a key which is a substring of other key.. by this, later you need to ignore the first member after split as it is empty.
How to readout the real selection?
now, having this string, you can simply split it (ignoring first member):
var list = SELECTION_Product.split(";");
var listOut = "";
list.forEach(function(element, index) {
if(element != "") {
listOut = listOut + " | " + element;
}
});
TEXT_2.setText(listOut);
In the place where I create the second output (line 5) you can make your code.
Application
In the given example, you can find 2 scorecards, the first one (_1DIM) has single dimension, as in this example. The second one (_2DIM) was a try to get out the selection with 2 dimensions - this failed for today... perhaps some other day I can find a script which makes it...
Download
The app can be downloaded here
Does anyone need an exact selection of combinations of 2 or more dimensions? to make it work, probably the selection API needs to be changed like "getRows()" and then "getDimensionKey("A")", etc.
feel free to comment and ask
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
13 | |
12 | |
11 | |
9 | |
9 | |
7 | |
5 | |
5 | |
5 |