This question is locked. New answers and comments are not allowed.
Hi
I wanted to check if the user types out an item that is NOT present in the items array then is it possible to push what the user has typed as a new item into the array and select the same.
Thanks
4 Answers, 1 is accepted
0
Anurag,
The RadAutocomplete control does not provide this functionality out-of-the-box.
However, you can access the native controls behind he RadAutocomplete and create your event handles (e.g., for textChange in Android) and implement your logic on what to happen when the user enters a non-existing token value.
For example:
Based on that approach you can now check how the user input has changed and introduce your new tokens on the fly.
Regards,
Nikolay Iliev
Progress Telerik
The RadAutocomplete control does not provide this functionality out-of-the-box.
However, you can access the native controls behind he RadAutocomplete and create your event handles (e.g., for textChange in Android) and implement your logic on what to happen when the user enters a non-existing token value.
For example:
var
autocmp = args.object;
// get reference to your RadAutoCompleteTextView either via loaded or via getViewById
console.log(
"autocmp: "
+ autocmp)
// RadAutoCompleteTextView
var
nativeTField = autocmp.android.getTextField();
console.log(
"nativeTextField: "
+ nativeTField)
// android.widget.EditText (the Android native widget EditText)
nativeTField.addTextChangedListener(
new
android.text.TextWatcher({
afterTextChanged(s) {
console.log(
"afterTextChanged"
);
console.log(s);
},
beforeTextChanged(s, start, count, after) {
console.log(
"beforeTextChanged"
);
console.log(s);
console.log(start);
console.log(count);
console.log(after);
},
onTextChanged(s, start, before, count) {
console.log(
"onTextChanged"
);
console.log(s);
console.log(start);
console.log(before);
console.log(count);
}
}));
Based on that approach you can now check how the user input has changed and introduce your new tokens on the fly.
Regards,
Nikolay Iliev
Progress Telerik
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Anurag
Top achievements
Rank 1
answered on 02 Oct 2017, 07:15 AM
Hi Nikolay
Thanks for the suggestion, it helps. Since I need a similar functionality on IOS as well, is there some way to achieve a similar outcome on IOS too.
Best,
Anurag
0
Anurag,
Accessing the events responsible for text change in UITextField (which is the extended native control behind the textField property in RadAutomcompleteTextView is a not a straightforward task, and we would not recommend it as it might change the way the control works. Currently, the only officially supported events for iOS are the one posted here.
However, if you want to experiment and provide custom logic, you can do that with overwriting the delegate method responsible for providing the methods for user interaction.
For example:
Example on how to overwrite a delegate method using TypeScript can be found here.
Once again this is not recommended approach as it could break your application if and when internal changes are made to RadAutocompleteTextView.
Regards,
Nikolay Iliev
Progress Telerik
Accessing the events responsible for text change in UITextField (which is the extended native control behind the textField property in RadAutomcompleteTextView is a not a straightforward task, and we would not recommend it as it might change the way the control works. Currently, the only officially supported events for iOS are the one posted here.
However, if you want to experiment and provide custom logic, you can do that with overwriting the delegate method responsible for providing the methods for user interaction.
For example:
let radAutomComplete = <RadAutoCompleteTextView>args.object;
let tkAutoComplete = radAutomComplete.ios
// TKAutoCompleteTextView http://docs.telerik.com/devtools/ios/api/Classes/TKAutoCompleteTextView.html
tkAutoComplete.delegate
// overwrite the delegate method http://docs.telerik.com/devtools/ios/api/Classes/TKAutoCompleteTextView.html#//api/name/delegate
Example on how to overwrite a delegate method using TypeScript can be found here.
Once again this is not recommended approach as it could break your application if and when internal changes are made to RadAutocompleteTextView.
Regards,
Nikolay Iliev
Progress Telerik
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Anurag
Top achievements
Rank 1
answered on 02 Oct 2017, 08:18 AM
Hi Nikolay
Thanks for your prompt response and your advice. In that case, I will avoid this approach and explore providing a different interface to add new text data to the items array. I have put in a feature request here to provide a way to easily access the text entered into the autocomplete view.
Regards
Anurag