Skip to Content
Author's profile photo Karol Kalisz

Design Studio 1.6 – Using Multiselect in Scorecard

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

applications/SCORECARD_SELECTION_MULTI-20160222223057.zip at master · org-scn-design-studio-community/applications · Git…

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

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      hi Karol Kalisz,

      there is  a "SELECTION_Product " (in the 1st script block) . where and how should it be defined ?


      thx,

      Kirill

      Author's profile photo Karol Kalisz
      Karol Kalisz
      Blog Post Author

      Hi,

      it is global script variable which you need to define in the application. It is only one way to pass values across different methods.

      Karol