Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48616

Re: How to multiSelect with selection manager in power bi custom visual

$
0
0

I have several remarks:

First of all, there is absolutely no need to invoke these functions using the apply() method:

The apply() method is used to set the "this" value of the invoked function to the one of the first argument passed to apply.

Both the or() function and the createWithIds() function don't even use their "this" value.

Also, passing a module("data") or a class("SelectionId") to the apply() method as the "thisArg" is wrong for so many reasons.

Another thing to note here is that if the invoked function accepts arguments, then any item in the "argsArray" passed the n-1 index will just be ignored by it(Unless it was specifically designed to handle a varying amount of arguments).

 

The or() function accepts two arguments, so If you want to create an "or" SQExpr between all items in an SQExpr objects collection, you should do something like this-

 

var myOrExpr = exprs[0];
for (var i = 1; i < exprs.length; i++) {
   myOrExpr = data.SQExprBuilder.or(myOrExpr, exprs[i]);
}

 

Note: This example is a bit simplified. You may have to type-assert the SQExprs(E.g. <data.SQExpr>expr) so you won't get compiler errors.

 

The SelectionId.createWithIds() method only accepts two DataViewScopeIdentityObjects as arguments and an optional highlight boolean value, so if you pass it an array of DataViewScopeIdentity objects in the apply() method, only the first two will be used, and if there is a third one, it will set the highlight boolean to true/false, depending on its value. The rest will be ignored.

The SelectionId class has no create method that accepts more than two DataViewScopeIdentity objects. Fortunately for you, you can also create an instance of this class by using the "new" keyword. The class' constructor, declared as follows-

 

constructor(selector: Selector, highlight: boolean);

accepts a Selector object as its first argument. The Selector interface defines a property called "data" of type DataRepetitionSelector[], which is an array of DataRepetitionSelector objects, which is a type defined as follows-

 

export type DataRepetitionSelector = DataViewScopeIdentity | DataViewScopeWildcard | DataViewRoleWildcard;

meaning that you can set its value to an array of DataViewScopeIdentity objects of any reasonable size.

 

Note: I noticed that order has a meaning when settings this array(I.e. different order results in different selection behavior), so keep that in mind.

 

Regarding the consulting engagement, I appreciate the offer, but unfortunately I don't have enough spare time to commit to this project at the moment(And also, I don't regard myself as an expert...). But feel free to ask more questions in the community if you encounter any more problems. I usualy try to help where I can.


Viewing all articles
Browse latest Browse all 48616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>