This is a migrated thread and some comments may be shown as answers.

FormControl supportin kendo-dropdownlist

4 Answers 2727 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
Jyothi asked on 05 Aug 2019, 07:07 PM

Hi,

I have seen some code in our project using formContol attribute. I couldn't find any documentation on it.  For some reason this is causing the default value not set on the dropdown.

dropdownPlaceholder is something like this

this.dropdownPlaceholder = {
label : `Select ${label}` ,
value : null
};

Example:

<kendo-dropdownlist [data] = "list"
[textField] = "'label'"
[valueField] = "'value'"
[defaultItem] = "dropdownPlaceholder"
style="background-color: inherit"
[valuePrimitive] = "true"
(valueChange) = "onDropdownValueChange($event)"
[popupSettings] = "{popupClass: 'facets-input-dropdown-popup', width: 'auto'}"
[disabled] = "isDisabled"
[formControl]="control">

I expect the default value to be 'Select' in the dropdown, but not seeing that. Any documentation on formControl attribute for kendo-dropdownlist will be helpful.

Regards,

Jyothi

4 Answers, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 06 Aug 2019, 02:09 PM
Hi Jyothi,

If I understand correctly, the [defaultItem] input for the DropDownList is not working with reactive forms. I have tried to replicate the provided example in a StackBlitz here - https://stackblitz.com/edit/angular-amqjpx
It looks like it is working as expected - the default value is taken from dropdownPlaceholder. Am I missing something?

Also you can find the docs on using Reactive forms(i.e. formControl) with kendo-dropdownlist here - https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/forms/#toc-reactive-forms

Regards,
Petar
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 06 Aug 2019, 03:09 PM

Hi Petar,

Thanks. This is very helpful.

Regards,

Jyothi

0
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 06 Aug 2019, 03:15 PM

Sorry I hit the button too soon.

Does it support [formControl] tag as well? I see the example using the formControlName="gender"

 

Regards,

0
Petar
Telerik team
answered on 08 Aug 2019, 02:16 PM
Hi Jyothi,

The DropDownList works with reactive forms, meaning both [formControl] and formControlName will work.

In this example - https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/forms/#toc-reactive-forms formControlName is used.

In this example - https://stackblitz.com/edit/angular-amqjpx [formControl] is used.

The two approaches are used in different situations. You can read more on Angular's Reactive forms here - https://angular.io/guide/reactive-forms

I hope this helps.

Regards,
Petar
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Petar
Telerik team
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or