Hi! Trying to set initial values on filters like t...
# gooddata-ui
m
Hi! Trying to set initial values on filters like this // This works const [filterMthCode, setFilterMthCode] = useState( newPositiveAttributeFilter(Md.MthCode_1, { uris: ["/gdc/md/is8qa659w0r0dbgl8bbrcgh0ovrr5fgp/obj/1046/elements?id=255"], // Default value }), ); // This doesn't, passing the values const [filterMake, setFilterMake] = useState(newPositiveAttributeFilter(Md.CorrMake, ["RENAULT"])); I get error in console, The attribute elements must be defined by URIs for this backend. Did I miss a step or config? How do I know the URI of a possible value in filter component?
Actually, the filter applies just fine it's the <AttributeFilterButton filter={filterMake} onApply={setFilterMake} /> That gives an error.
Would be helpful to make it work by values, not just uris.
j
Hello @Michael Serres! What backend implementation are you using? Is it codename Bear (hosted GoodData Platform), or is it codename Tiger (GoodData.CN)? To get the URI of a possible value, please see the validElements example at https://gdui-examples.herokuapp.com/attribute-filter-components, or you can simply GET the URL:
<https://your.domain.com/gdc/md/is8qa659w0r0dbgl8bbrcgh0ovrr5fgp/obj/12345/elements>
where
12345
is obj id of your displayForm (label). To get the obj id of your displayForm (label), simply GET the URL:
<https://your.domain.com/gdc/md/is8qa659w0r0dbgl8bbrcgh0ovrr5fgp/obj/12344>
where
12344
is the obj id of your attribute. To get the list of all attributes, simply GET the URL:
<https://your.domain.com/gdc/md/is8qa659w0r0dbgl8bbrcgh0ovrr5fgp/query/attributes>
. You should be able to visit all the GET URLs in your browser too to visually validate — see the attached screenshots. Please let me know if it helped!
🙌 1
I see you found the note. I will let our Product team know it would be helpful if the <AttributeFilterButton /> component supported identifiers too. @Andy @Andrey Skripnikov @Martin Svadlenka In the meantime, you can either go with URIs — but make sure to get them dynamically to preserve multitenancy of your app — or you can opt-in for an <AttributeFilter /> component instead.
👀 1
m
Yes <AttributeFilter /> is great but seeing the selected values in the button one is super valuable... Now I have to do this
I'm using react, gdui and hosted platform. I think that's what you call Bear.
👍 1
p
🎉 New note created.