You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the onFastEntryFinished event to handle entered text lines the way your require.
import{SurveyCreatorModel}from"survey-creator-core";constoptions={ ... };constcreator=newSurveyCreatorModel(options);creator.onFastEntryFinished.add((_,options)=>{// `options.lines` - An array of entered text lines// `options.items` - An array of choices that were created based on the entered text linesoptions.items[0].text="Custom display text";options.items[0].value="Custom value";});
Choices with a corresponding value and text will be created.
However, if you do not explicitly specify the value attribute, as follows:
Option-1
Option-2
Option-3
Option-4
Option-5
Those strings will be used as values:
In a usage scenario, it's required to use supplied strings as texts and auto-generate ordered numbers for these choices to achieve the following output:
Consider introducing an API which would allow developers to manage auto-generated choices and override their values and texts. For the record: creator.onItemValueAdded is raised only when adding a new choice via the Add New button.
The text was updated successfully, but these errors were encountered:
#5525)
* Choices - Introduce an API which would allow defining the value for choices added via a Fast Entry editor fix#5514
* Fix unit tests
* Rename event and options type #5514
* Add descriptions
---------
Co-authored-by: RomanTsukanov <sergeich16@gmail.com>
RomanTsukanov
changed the title
Choices - Introduce an API which would allow defining the value for choices added via a Fast Entry editor
Choices: Introduce an API that would allow defining the value for choices added using a Fast Entry pop-up editor
May 29, 2024
RomanTsukanov
changed the title
Choices: Introduce an API that would allow defining the value for choices added using a Fast Entry pop-up editor
Choices: Introduce an API to define the value for choices added using a Fast Entry pop-up editor
May 29, 2024
IMPLEMENTED
Use the
onFastEntryFinished
event to handle entered text lines the way your require.Documentation
T18227 - Automatic choice injection
https://surveyjs.answerdesk.io/internal/ticket/details/T18227
When you use the fast entry editor, you expect to specify the value and text separated by
|
.Choices with a corresponding value and text will be created.
![image](https://private-user-images.githubusercontent.com/22372972/332376411-b3381d3a-4583-4e08-a0ad-80075767ce51.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNzYxNDgsIm5iZiI6MTcxOTI3NTg0OCwicGF0aCI6Ii8yMjM3Mjk3Mi8zMzIzNzY0MTEtYjMzODFkM2EtNDU4My00ZTA4LWEwYWQtODAwNzU3NjdjZTUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI1VDAwMzcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzNTY1NTE2NzUxOWY4MDliODE2NjAzNTU3NmRkMzJiNzcyM2VkNTU3OGMzYzg2ODA4OGE0YWRhYTg4OTUwZmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.cQ5eRVHcoC4otWPT15Htmd4FcIjP9F-TijbjEE6fTi4)
However, if you do not explicitly specify the value attribute, as follows:
Those strings will be used as values:
![image](https://private-user-images.githubusercontent.com/22372972/332376767-52fb5b9f-b3c7-4b32-abee-7964dd36585c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNzYxNDgsIm5iZiI6MTcxOTI3NTg0OCwicGF0aCI6Ii8yMjM3Mjk3Mi8zMzIzNzY3NjctNTJmYjViOWYtYjNjNy00YjMyLWFiZWUtNzk2NGRkMzY1ODVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI1VDAwMzcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNhNThlM2IzNjhiMDEwMDY4NmFlYmViNzk3YWM2NzJjYWFlMmZmMzg5OTQzZGVmYTYxMGEwYjY0MGRkNmU2ODYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.OjNWTy3_dp7pMhck8RYBGOmPWps9_EAUqdrSkA0eU14)
In a usage scenario, it's required to use supplied strings as texts and auto-generate ordered numbers for these choices to achieve the following output:
![image](https://private-user-images.githubusercontent.com/22372972/332377132-cc5532bc-ac5d-4f5c-89f3-fc156eac4c0d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNzYxNDgsIm5iZiI6MTcxOTI3NTg0OCwicGF0aCI6Ii8yMjM3Mjk3Mi8zMzIzNzcxMzItY2M1NTMyYmMtYWM1ZC00ZjVjLTg5ZjMtZmMxNTZlYWM0YzBkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI1VDAwMzcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThjODc2YThmNWFlNjI5MGI1MmNiYmQzNjZiNmFiZDFlZGRmNjBiMTY4Y2NjNzA4OGQ2YWMxN2E1MDZkMWRjMjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Ykn7Shsw3gz-863Q8hngksWk8gY0en_p9dJrp9XM2CM)
Consider introducing an API which would allow developers to manage auto-generated choices and override their values and texts. For the record: creator.onItemValueAdded is raised only when adding a new choice via the Add New button.
The text was updated successfully, but these errors were encountered: