can we restrict not toggle option to a single level rule? #626
Answered
by
jakeboone02
kuljeet2604
asked this question in
Q&A
-
Hi |
Beta Was this translation helpful? Give feedback.
Answered by
jakeboone02
Jan 8, 2024
Replies: 1 comment 1 reply
-
You can achieve this with a custom https://codesandbox.io/p/devbox/infallible-star-h8v3td?file=%2Fsrc%2FApp.tsx%3A19%2C1-32%2C1 const CustomRuleGroup = (props: RuleGroupProps) => {
if (props.context?.parentHasNotTrue) {
return (
<RuleGroup
{...props}
schema={{ ...props.schema, showNotToggle: false }}
/>
);
} else if (props.ruleGroup.not) {
return <RuleGroup {...props} context={{ parentHasNotTrue: true }} />;
}
return <RuleGroup {...props} />;
};
export const App = () => {
const [query, setQuery] = useState(initialQuery);
return (
<QueryBuilder
fields={fields}
query={query}
onQueryChange={setQuery}
showNotToggle
controlElements={{ ruleGroup: CustomRuleGroup }}
/>
);
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kuljeet2604
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can achieve this with a custom
RuleGroup
component:https://codesandbox.io/p/devbox/infallible-star-h8v3td?file=%2Fsrc%2FApp.tsx%3A19%2C1-32%2C1