custom combinator component, like toggle or radio instead of dropdown, can we have this feature? #617
Answered
by
jakeboone02
kuljeet2604
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
jakeboone02
Dec 21, 2023
Replies: 2 comments
-
Use the Example with radio buttons: import { useId } from 'react';
import { QueryBuilder, ValueSelectorProps } from 'react-querybuilder';
const MyCombinatorSelector = (props: ValueSelectorProps) => {
const name = useId();
return (
<>
<label>
<input
type="radio"
name={`combinator-${name}`}
checked={props.value === 'and'}
onClick={e => props.handleOnChange('and')}
/>
{'AND'}
</label>
<label>
<input
type="radio"
name={`combinator-${name}`}
checked={props.value === 'or'}
onClick={e => props.handleOnChange('or')}
/>
{'OR'}
</label>
</>
);
};
// Implementation:
<QueryBuilder
fields={fields}
query={query}
onQueryChange={onQueryChange}
controlElements={{
combinatorSelector: MyCombinatorSelector,
}}
/> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jakeboone02
-
thanks this works ✌🏻 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the
controlElements
prop (documentation), specifically thecombinatorSelector
property (documentation).Example with radio buttons: