Kendo-angular: [defaultItem] attribute in kendo-dropdownlist depulicates the default item.

Created on 14 Jan 2019  路  1Comment  路  Source: telerik/kendo-angular

I'm submitting

a bug report.

Current behavior

When using kendo-dropdownlist and including a defaultItem attribute, the defaultItem is correctly selected by default, but is duplicated in the dropdown list.

Expected behavior

The default item should be selected by default, but should only remain in the dropdown list once. It should not be duplicated and appear at the top of the dropdown.

Minimal reproduction of the problem with instructions

  1. Create an array of strongly typed complex objects.

image

  1. Add a kendo dropdownlist component into the html. Make sure the [data] property is the array in the previous step. Also, add a [defaultItem] attribute that is set to an item in the data array.
    image

  2. The dropdown correctly defaults to the defaultItem, but it adds the item at the top of the dropdown list as well as keeping it in the correct index.

image

Environment

Package versions:

  "@angular/animations": "~7.0.0",
    "@angular/common": "~7.0.0",
    "@angular/compiler": "~7.0.0",
    "@angular/core": "~7.0.0",
    "@angular/forms": "~7.0.0",
    "@angular/http": "~7.0.0",
    "@angular/platform-browser": "~7.0.0",
    "@angular/platform-browser-dynamic": "~7.0.0",
    "@angular/router": "~7.0.0",
    "@progress/kendo-angular-buttons": "^4.1.3",
    "@progress/kendo-angular-charts": "^3.5.2",
    "@progress/kendo-angular-dateinputs": "^3.4.4",
    "@progress/kendo-angular-dialog": "^3.5.0",
    "@progress/kendo-angular-dropdowns": "^3.4.1",
    "@progress/kendo-angular-excel-export": "^2.2.0",
    "@progress/kendo-angular-grid": "^3.10.2",
    "@progress/kendo-angular-inputs": "^3.4.0",
    "@progress/kendo-angular-intl": "^1.4.0",
    "@progress/kendo-angular-l10n": "^1.1.0",
    "@progress/kendo-angular-label": "^1.0.7",
    "@progress/kendo-angular-layout": "^3.2.0",
    "@progress/kendo-angular-menu": "^1.2.0",
    "@progress/kendo-angular-popup": "^2.2.0",
    "@progress/kendo-angular-resize-sensor": "^3.1.2",
    "@progress/kendo-angular-ripple": "^1.1.0",
    "@progress/kendo-angular-sortable": "^2.0.0",
    "@progress/kendo-angular-treeview": "^2.2.0",
    "@progress/kendo-data-query": "^1.4.1",
    "@progress/kendo-drawing": "^1.1.2",
    "@progress/kendo-theme-default": "latest",
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/cli": "^7.0.6",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/language-service": "~7.0.0", 
  }
}

Browser:

  • Chrome (desktop) version 71.0.3578.98 (Official Build) (64-bit)
Question dropdowns

Most helpful comment

The default item is an additional item that is not part of the data. Its purpose is to be selected when the component has no value. To set initially selected item from the data, set the component value:
https://stackblitz.com/edit/angular-wqnalg?file=app/app.component.ts

>All comments

The default item is an additional item that is not part of the data. Its purpose is to be selected when the component has no value. To set initially selected item from the data, set the component value:
https://stackblitz.com/edit/angular-wqnalg?file=app/app.component.ts

Was this page helpful?
0 / 5 - 0 ratings