Replies: 1 comment 4 replies
-
Please clarify for me: you want the field selector to be a simple text editor until the API returns a non-empty array, and then the field selector should be a drop down menu? I'm curious why you'd display a free-form text box instead of a "loading" message or an empty But to achieve your goal, you'd need a custom field selector that returned const CustomFieldSelector = (props: FieldSelectorProps) => {
if (props.options.length === 0) {
return <input type="text" onChange={e => props.handleOnChange(e.target.value)} />;
}
return <ValueSelector {...props} />;
}
// App component returns:
<QueryBuilder
fields={fields} // <-- This prop should be updated by your API
controlElements={{ fieldSelector: CustomFieldSelector }}
/> |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, I'm currently working on a React querybuilder. React querybuilder works very well, no problems. However, I'm trying to do something a bit complex and I can't find the tools to help me with this task, which is as follows: When I select a field, I have to call an API that will return either an empty array or an array of data. If the array is empty, we simply return a classic text input, otherwise we return a selection with the data I'm retrieving from the API as an option.
This is to avoid loading all the api at once and overloading the backend. So I don't know if I should update the fields or update the rule directly. I hope I've been clear enough about my problem and I'd like to thank in advance anyone who can take the time to help me solve it.
Beta Was this translation helpful? Give feedback.
All reactions