Hi, I'm using Dashboard from '@gooddata/sdk-ui-das...
# gooddata-ui
m
Hi, I'm using Dashboard from '@gooddata/sdk-ui-dashboard' to view a dashboard already created and it works fine, but i need to set a filter attributeFilter with some value. I already did it in a kpi component as IKpiProps has filters that can be set but I couldn't figure it in IDashboardProps. What i need is to load the dashboard filtered by some attribute value. Please note that I'm using angular.
j
Hello @Mohammad Zahr! You are correct that other components accept the
filters
prop, e.g. the <Kpi /> component. However, with the <Dashboard /> component it is a bit more complex since it must handle the filterContext of the dashboard together with filters on each individual insight. If you take a look into our CHANGELOG you'll see that with the latest GoodData.UI version 8.9 "The dashboard commands and events related to filter modification were included in the public API." The best documentation to use would be the one directly in the source code (convenient if you use some smart IDE like Visual Studio Code), but if you want to read some theory, I'd recommend the Commands paragraph of the Dashboard component. Let me know if this is what you're looking for! Jiri
m
Hi, I checked it and saw the commands but I didn't find the command I need because the attribute that I need to filter on it is not in the dashboard filters. So I can't use ChangeAttributeFilterSelection because this attribute is not in the filters. What I need is to filter by any attribute and it doesn't have to be up in the filters. Any suggestions ?
Also I tried to use it just for testing I tried addAttributeFilter command but it's not working, I'm getting an error
Invariant Violation: Hooks can only be called inside the body of a function component.
Note that I'm using angular so it's not a function component like in react.
j
Hello @Mohammad Zahr! It might be the case that you cannot filter a dashboard by an attribute that is not listed in the filter bar. I see you're trying to add the filter dynamically, but failing to do so since you're in Angular and therefore the Hooks error does not really apply to you. I need to ask @Dan Homola if he has any experience with how to use React Hooks in Angular. Dan, could you please help? 🙏
d
Hi all, for non-react uses, it might be useful to use the mechanism described here that allows you to trigger commands on the dashboard from outside. Then you can use the commands described in the Commands as linked by @Jiri Zajic. As for the filters that are not already on the dashboard, the commads that allow adding them are not yet part of the public API, so I suggest if you want to filter by some filter to add it with all values selected when creating the dashboard and then changing them using the applyAttributeFilter command creator in your embedding use. Hope this helps 🙂
👍 1
🙏 1