Completed
Last Updated: 20 Sep 2021 14:02 by ADMIN
Tim
Created on: 22 Feb 2018 18:12
Category: Kendo UI for jQuery
Type: Feature Request
8
Add methods to allow any property to be changed after initialization
There are many properties that can be set during initialization that cannot be changed through the API afterwards.

Take the Kendo UI ToolBar for example. You can add a button to the toolbar and set the text, but you cannot change the text afterwards unless you update the element directly. It may seem like a simple thing to change the text of an element, like so: $("#myButton").text("New Text"). However, if you had set the imageUrl as well, setting the text like I did above would remove the image. Knowing that, you could get the text node and update the nodeValue. That may work today but could easily be broken during a Kendo UI update (for example, if the update included a change that wraps the text in a span).

Having to deal with native elements after they have been created by the Kendo UI components is a dangerous practice for developers as it requires an internal knowledge of how elements are rendered based on the different options set. As mentioned above, it is also dangerous as any update could break our code. Therefore, it is imperative to expose methods that allow us to modify any properties through the API (where possible) to allow us to create clean and easy to maintain code.

If you search the feedback, you will see many requests to add a method here and a method there. There is even a related one to this called "Kendo Mobile: Methods to set properties dynamically".

Suggestion: When you have child elements, such as buttons on the toolbar, please allow us to update those widgets directly rather than through the parent. For example, instead of $("#myToolbar").data("kendoToolBar").enable("#myButton"), allow us to do something like this $("#myButton").data("kendoToolBarItem").enable();
1 comment
ADMIN
Nencho
Posted on: 20 Sep 2021 14:02

Hello, Tim,

The setOptions method is the one that's recommended for the usage that you've described. 

https://docs.telerik.com/kendo-ui/api/javascript/ui/widget/methods/setoptions 

However, it's inevitable to reinitialize the component, as most of the changes in the component options require rendering changes.

Regards,
Nencho
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.