Programatically select dropdown item

4 posts, 0 answers
  1. Dominik
    Dominik avatar
    6 posts
    Member since:
    Feb 2019

    Posted 29 Sep Link to this post

         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>

  2. Martin
    Admin
    Martin avatar
    253 posts

    Posted 01 Oct Link to this post

    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/.

  3. Dominik
    Dominik avatar
    6 posts
    Member since:
    Feb 2019

    Posted 10 Oct in reply to Martin Link to this post

    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...

  4. Martin
    Admin
    Martin avatar
    253 posts

    Posted 12 Oct Link to this post

    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/.

Back to Top