Using wrapped kendo textbox control with reactive forms

0 Answers 1891 Views
TextBox
Kristof
Top achievements
Rank 1
Iron
Iron
Kristof asked on 20 May 2021, 10:09 AM

Hi,

We are creating a custom control which contains a kendo textbox. (The custom control only contains the kendo-textbox)
We want to use reactive forms with the formGroup/formControlName in this custom control on the kendo-textbox

How can I achieve this one?

thanks!

Preslava
Telerik team
commented on 25 May 2021, 06:12 AM

Hi Kristof,

Indeed, the TextBox can be used in a reactive form. 

Please, check the following example, which demonstrates the desired form:

https://stackblitz.com/edit/angular-qnvxtu-nc3ccx?file=app/app.component.ts 

The example above also showcases how to set validators and validation icons, if such are needed.

More information and another demo could be found here:

https://www.telerik.com/kendo-angular-ui/components/inputs/textbox/forms/#toc-reactive-forms

Let me know, if this information helps.

Kristof
Top achievements
Rank 1
Iron
Iron
commented on 25 May 2021, 05:40 PM | edited

Hi Preslava,

This is our setup:
A page (Angular component) contains a '<custom-textbox>' (Angular component)
The custom-textbox component contains the <kendo-ui textbox> component.

The page has a <form> using the reactive forms and the custom-textbox need to set the formControl(Name) on the underlying kendo-ui textbox.

At this moment i created an input-property on the custom-textbox of type FormControl, which is bound to the 'formControl' property on the kendo-ui textbox.

I was wondering if this is the right way to do.
Preslava
Telerik team
commented on 28 May 2021, 10:49 AM

Hi Kristof,

Yes, this seems correct. 

No answers yet. Maybe you can help?

Tags
TextBox
Asked by
Kristof
Top achievements
Rank 1
Iron
Iron
Share this question
or