Populate coded values via code only (ignoring text)
See original GitHub issueA proposal / question
It would be great if the logic of the surveys would be able to operate on coded choices only (if coded) and ignore the text labels.
What is the current behavior?
I’m not sure (yet how the filtering & conditions work), but for populating/ setting data, it only works if both code and text match.
A simple example of what I mean.
let’s say I have a question like :
{
type: "radiogroup",
name: "car",
title: "What car are you driving?",
isRequired: true,
choices: [
{'code':1, "text":"Ford"},
{'code':2, "text":"BMW"},
{'code':3, "text":"Ziguli"}
]
}
right now, in order to set the value, one would need to have it like:
survey.data = {car: {code:1,text:'Ford'}};
What is the expected behavior?
I think it would be logical if only this would be enough:
survey.data = {car:1};
If the choices are coded, using codes will resolve numerous issues like
- simplicity
- translation issues (having texts in various languages needs separate attention & a layer of management)
- Changeability. Mostly you need to change the label / text only. What if you change the form coded text and you have some values stored with a different text?
- less data to store. Storing
{car:1}
takes much less space than{car: {code:1,text:'Ford'}}
Imagine if you would have some code in the text labels (eg html).
Thank you for a cool library!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to make html ignore code that is part of text?
Short Answer. Encode your code using an online HTML Encoder and then put it inside pre <pre> <%--your encoded code goes here--%> </pre>....
Read more >Keeping leading zeros and large numbers
Excel automatically removes leading zeros, and converts large numbers to scientific notation, like 1.23E+15, in order to allow formulas and math operations to ......
Read more >Excel conditional formatting formulas based on another cell
This method works for any data types: numbers, text values and dates. Select the column where you want to highlight duplicates, without the ......
Read more >Excel Data Validation Tips and Troubleshooting
Why does this happen, and how can you prevent it? Get the sample file in the download section. drop down list blank. Cause:...
Read more >Text formatting tags—ArcGIS Pro | Documentation
The Annotation syntax applies to text in the page layout, the values of fields used to label ... Use the equivalent character codes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TonisOrmisson You should use value in expressions and it means that
{haveKids}=5
works perfectly.choices : [1, 2]
is the same aschoices : [{value: 1}, {value: 2}]
and text is optional and surveyjs uses it for displaying in UI only. Adding text as:choices : [{value: 1, text: "first year"}, {value: 2, text: "second year"}]
doesn’t change the way it works in expression.Thank you, Andrew
@andrewtelnov thank you!
You are completely right. And seems the setting also works perfectly. It seems that my mistake was wrongly using
code
instead ofvalue
. 🤦♂️excellent work guys