How can we axis the title of the filter, lets's sa...
# gooddata-ui
How can we axis the title of the filter, lets's say for Gender filter we have 'M' and 'F', When one select either of it it should give that 'M' or 'F' rather than the uris, which is specific to goodData.
Hi Pushkar. If I am understanding you right you are trying to achieve this: 1. User selects a filter 2. That filter outputs the value which is displayed on it into your application 3. You use that value to query some sort of DB in your environment. Is this right?
Yes, consider this example of the Gender filter itself. If I select 'M' then 'M' will be the output which I can use directly to query the DB in backend (In my case it is PostgreSQL). By doing so I am trying to make the filter not specific to GoodData charts or table.
You should define the attributeFilters with an onApply function that outputs the filter to your desired variable. For example, whenever you apply a filter with this code, the filter object will be logged to the console:
Copy code
const onApply = (filter) => {

	return (
			<AttributeFilterButton filter={newPositiveAttributeFilter(md.CustomerWeb, [])} onApply={onApply} />
You can then navigate to it like so:
Hey Jan, this is what I am getting. it says error loading filter after the first select.
Could you share your code with us? It’d be easier to diagnose if we know what you are doing 🙂
_const_ [gender_filter, setGenderFilter] = *useState*(
onApply={(gender_filter) _=>_ {
I will check and get back to you!
Hello again. There seems to be something going wrong here even on my end. I will try to get you an answer by tomorrow, but at the moment, the filter appears to be breaking after the first re-render if the value isn’t empty.
And hello again. Try changing
Copy code
Copy code
newPositiveAttributeFilter(Md.Gender,{uris: []}),
This should get it working.
Yes you are right, it works like that, but then I will not get the Value: 'M' or 'F' after the selection, which is what I need.
If somehow I am able to fetch that value, then it simplifies my task.
I will get the uris value, but what I need is the value which I select 'M' or 'F' in this case.
Unfortunately, with the hosted GoodData platform backend, it is not possible to use the attribute values as a filter - it only accepts the URIs. It is possible to convert those URIs into the AttributeFilter values by calling the backend separately, though. Alternatively, GoodData.CN does allow for filtering using the values, but that’s a whole different beast.
Sorry about the misunderstanding earlier - I wasn’t aware of the hosted platform’s limitation in terms of the attribute values.
No worries, thanks for your help🙂