Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 how disable kendo-dropdownlist

I'm trying to get a kendo-dropdownlist disabled (named ddlChargeType).

A user should not be able to directly select a value. But it should be possible to select it programmatically (a valid selection of another dropdown, ddlUoM to trigger the selection of a corresponding ddlChargeType option - this works fine).

So, my question is: how to mark my kendo-dropdownlist ddlChargeType as readonly, or disabled, or ng-disabled?

I couldn't find this in the official documentation:

http://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/

Thanks!

like image 339
Miha Avatar asked Dec 21 '16 00:12

Miha


People also ask

How do I get rid of kendo dropdown?

var dropdownlist = $("#dropdownlist"). data("kendoDropDownList"); dropdownlist. destroy();

What is Kendo Dropdownlist?

The Kendo UI for Angular DropDownList is a form component that lets you choose a single predefined value from a list. It is a richer version of the <select> element and supports data binding, filtering, templates, and default items.


2 Answers

With a constant value use:

<kendo-dropdownlist [data]="listItems" disabled="'true'"></kendo-dropdownlist>

With a component value:

@Component({
  selector: 'my-app',
  template: `
    <kendo-dropdownlist [data]="listItems" [disabled]="disabled"></kendo-dropdownlist>`
})
class AppComponent {
    public listItems: Array<string> = ["1", "2", "3"];
    public disabled: true;
}

Reference: http://www.telerik.com/kendo-angular-ui/components/dropdowns/api/DropDownListComponent/#toc-delay

like image 97
Piou Avatar answered Sep 19 '22 13:09

Piou


If [disabled]="disabled" didn't work you can use [attr.disabled]="disabled?true:null" instead of [disabled]="disabled"

@Component({
  selector: 'my-app',
  template: `
    <kendo-dropdownlist [data]="listItems" [attr.disabled]="disabled?true:null"></kendo-dropdownlist>`
})
class AppComponent {
    public listItems: Array<string> = ["1", "2", "3"];
    public disabled: true;
}
like image 34
Pedram A. Keyvani Avatar answered Sep 18 '22 13:09

Pedram A. Keyvani