简体   繁体   中英

How to disable/enable kendo-daterange programmatically? (without JQuery)

I have the following template在此处输入图片说明

and it works fine. The daterange is disabled. But if I remove these inline "disabled" attributes and if I want to disable/enable it via the button click programmatically, it doesn't work even though "disabled" attribute will be added into the elements. 在此处输入图片说明

How can I do this?

Use property binding syntax instead of using toggleAttribute :

Something like this:

<kendo-dateinput ... [disabled]="somePropertyOnYourComponent" ></kendo-dateinput>

And then in test :

test() {
  ...
  somePropertyOnYourComponent = true;
}

The approach with property binding works fine but if for whatever reason you want to use plain JS (TS) you need to disable/enable 4 elements (2 kendo-dateinput and 2 autogenerated by kendo internal inputs) 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM