Forum Discussion
Custom Visual - Selecting, Filtering and Highlighting
- 8 years ago
Partial solution to the selection problems (issues 1 and 2), but not the fact that other visuals are filtered not highlighted (3).
The problem stems from the fact that when more than one category column is add to createSelectionIdBuilder() it causes the cross-filtering to error when more than one data point is selected.
The fix is to only add one category column to the createSelectionIdBuilder - it doesn't matter which one, and the values in the column appear to be irrelevant. This is counter intuitive if comparing with an SQL select, or any other filtering function which would look to match against the values in the category columns. The resultant code (showing the removed line commented out) is as follows:
const selectionId: ISelectionId = this.host.createSelectionIdBuilder() .withCategory(ageRange, i) // .withCategory(gender, i) .createSelectionId();It would be helpful if PowerBI provided a more useful error message, or error checking, to advise that more than one category is not permitted when cross filtering; or even, have a solution which doesn't throw an error when more than one category is selected.
Hi v-viig
I tried cross-filte by cross-select as below.
This is my coding.
------------
let rowSelection: ISelectionId = this.visualHost.createSelectionIdBuilder()
.withTable(this.dataView.table, rowIndex)
.createSelectionId();
await this.selectionManager.select(rowSelection, true).then(result => {
console.log(result);
});
--------------
This is the relevant settings in capabilities.json
------------
"general": {
"displayName": "General",
"properties": {
"selection": {
"displayName": "Selection",
"type": {
"text": true
}
},
"filter": {
"type": {
"filter": true
}
},
"selfFilter": {
"type": {
"filter": {
"selfFilter": true
}
}
}
}
}
-----------------
But this didn't cross-select the passed selectionID row in other visuals of the page.
What could be the reason. Any specific config setting in tsconfig, capabilities.json or webpack.config?
Or
is there a specific way of adding ISelectionId objects of table mapping data to a dataPoints array of visual.
Currently I havent add to dataPoints array, but directly called the method,
this.selectionManager.select(rowSelection, true)
Please advise.
Thanks in advance,
Lasantha