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

Programatically select dropdown item

3 Answers 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Dominik
Top achievements
Rank 1
Veteran
Iron
Dominik asked on 29 Sep 2020, 09:45 AM

     Hi,

 

I am looking for option to programatically select value in combobox. I have array of objects binded to data. I have tried valueChange.emit(), selectionChange.emit(), .value changing, and changing selectedValue binded to ngmodel... nothing works.

<kendo-combobox
        #searchAreaCombobox
        id="searchAreaCombobox"
        [filterable]="false"
        [data]="listItems"
        class="k-combobox"
        [valueField]="'id'"
        [textField]="'caption'"
        [allowCustom]="false"
        [placeholder]="'searchAreaDropDown.placeholder' | translate"
        [(ngModel)]="selectedValue"
        (valueChange)="changeSearchArea($event)"
    >
    </kendo-combobox>

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 01 Oct 2020, 06:16 AM

Hello Dominik,

Based on the provided information is not clear enough, when the value of the ComboBox should be changed.

The valueChange and selectionChange events are emitted when the user selects an item from the Combobox dropdown. But, when the value is changed programmatically, these events are not triggered, as it is expected that the developer should know when the new value is assigned.

Please note that the new value of the selectedValue property must be in the same format as the bound data objects (having id and caption properties).

Here is an example where the value of the ComboBox is changed with a custom button:

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

In case of further questions, please provide some details about the use case. Thank you in advance.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Dominik
Top achievements
Rank 1
Veteran
Iron
answered on 10 Oct 2020, 04:04 PM

Thanks, finally it works, but it strange because it works like it works valueChange or selectionChange. Not both in one time I have to remove binding of one of it.

 

Big problem is for me because none of this events fires when user select the same option like previous :(.

But finally i solved a problems by workarounds...

0
Martin
Telerik team
answered on 12 Oct 2020, 11:47 AM

Hello Dominik,

I am glad to hear that you have managed to resolve the issue.

When choosing an already selected file the events are not triggered since the value is not changed actually.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ComboBox
Asked by
Dominik
Top achievements
Rank 1
Veteran
Iron
Answers by
Martin
Telerik team
Dominik
Top achievements
Rank 1
Veteran
Iron
Share this question
or