Angular 2如何禁用kendo-dropdownlist

时间:2016-12-21 00:03:59

标签: angular kendo-dropdown

我试图禁用kendo-dropdownlist(名为ddlChargeType)。

用户不应该直接选择值。但应该可以通过编程方式选择它(另一个下拉列表的有效选择,ddlUoM触发选择相应的ddlChargeType选项 - 这样可以正常工作)。

所以,我的问题是:如何将我的kendo-dropdownlist ddlChargeType标记为只读,禁用或禁用ng?

我在官方文档中找不到这个:

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

谢谢!

3 个答案:

答案 0 :(得分:2)

使用恒定值:

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

使用组件值:

@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;
}

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

答案 1 :(得分:0)

如果 [disabled] =“ disabled” 不起作用,则可以使用 [attr.disabled] =“ disabled?true:null” 代替[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;
}

答案 2 :(得分:0)

使用Angular 2/3/4/5/6/7试试这个[disabled] =“ true”

  <kendo-dropdownlist id="ddlSegment" name="ddlSegment" class="arcm-form-control" [data]="filterList?.SegmentList"  [disabled]="true"
    [textField]="'Segment_Desc'" 
      [valueField]="'ARCM_Segment_ID'"  (selectionChange)="segmentSelectionChange($event)" [(ngModel)]="selectedSegment"  >
    </kendo-dropdownlist>