kendo-dropdownlist disappears when I select a value that is -1

0 Answers 51 Views
DropDownList
Rory
Top achievements
Rank 1
Rory asked on 22 Jun 2022, 08:15 AM

I have a dropdown within a for loop that looks like this:

<kendo-dropdownlist
	[name]="'Type_Name_' + index"
	[data]="this.types"
	[textField]="'name'"
	[valueField]="'id'"
	[ngModel]="{
		id: UserInfo.TypeId,
		name: this.types[UserInfo.TypeId].name
	}"
	(selectionChange)="onTypeChange($event, UserInfo)"
>
	<ng-template kendoComboBoxItemTemplate let-dataItem>
		<span [title]="dataItem.name">{{ dataItem.name }}</span>
	</ng-template>
</kendo-dropdownlist>

types: any = [];

The types are pulled from the DB and look like this:
[
  {
    "id": -1,
    "name": "Select"
  },
  {
    "id": 1,
    "name": "A type"
  },
  {
    "id": 2,
    "name": "Another Type"
  }
]

 

The dropdown loads ok. But when I choose the value "Select" which is -1 the whole dropdown disappears.
Similarly because this is in a for loop I allow more dropdowns to be dynamically added.

When I dynamically add them with a value of -1 they don't appear. When I add them with a value of 0 they do appear.

I'm constricted to use -1 as the start value.

No answers yet. Maybe you can help?

Tags
DropDownList
Asked by
Rory
Top achievements
Rank 1
Share this question
or