Hello,
In the logic category, we have Empty, Not empty, Equals, Does not equal, etc…
Is there a way to remove some of these and keep only Greater than and Less than?
We have closed this ticket because another page addresses its subject:
Change "visible if" dropdown options in the survey editorHello,
In the logic category, we have Empty, Not empty, Equals, Does not equal, etc…
Is there a way to remove some of these and keep only Greater than and Less than?
Hello Ali,
Logic Operators are defined in the Survey Creator's settings.operators array. You can delete unnecessary operators.
For instance, the following code removes the Empty and Not Empty operators:
JavaScriptdelete SurveyCreator.settings.operators["empty"];
delete SurveyCreator.settings.operators["notempty"];
Please let me know if you have any questions or require further assistance.
Thanks for the quick response!
I want to show/hide operators based on the "Select" question change (between question1, question3 and question4). All these questions have different type, so I want to show/hide operators based on the type of that selected question
Thank you for the clarification. I will research this task and check whether it is possible to remove operators based on a selected elements.
Please stay tuned.
Hello Ali,
If you wish to customize which operators will be available for question types, you can modify the settings.operators collection and define a list of unsupported questions for each operator. For example, in the following code, I set that the empty
operator is not available for the File question type. You can update the list of operators as your needs dictate.
JavaScriptimport { settings } from "survey-creator-core";
settings.operators = {
empty: [ "!file"],
notempty: [],
equal: ["!file" ],
notequal: ["!file"],
contains: ["checkbox", "text", "comment"],
notcontains: ["checkbox", "text", "comment"],
anyof: ["selectbase"],
allof: ["checkbox"],
greater: ["!checkbox", "!imagepicker", "!boolean", "!file"],
less: ["!checkbox", "!imagepicker", "!boolean", "!file"],
greaterorequal: ["!checkbox", "!imagepicker", "!boolean", "!file"],
lessorequal: ["!checkbox", "!imagepicker", "!boolean", "!file"]
}
You can also modify the default operator using the settings.defaultOperator property.
JavaScriptimport { settings } from "survey-creator-core";
settings.logic.defaultOperator = "notempty";
I hope this helps. Please let me know if you have any questions or require further assistance.