This is a migrated thread and some comments may be shown as answers.

Dynamically Change widget Style attributes

1 Answer 352 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Jonatan
Top achievements
Rank 1
Jonatan asked on 12 Jan 2016, 09:19 AM

I have browsed around and found several thread, concluding that style binding an kendo MVC widget is just not supported.

Example of style binding: $('#kendoWidgetID').attr("data-bind", "style : { backgroundColor : modelColorAttribute } ");

I have, however, been unable to determine the following.

1: Is it in the works? Or will it be?

2: If style binding is not supported on kendo MVC Widgets, then how on earth am I meant to dynamically change the styles of my kendo widgets on my grid popup, depending on my selected model properties?

 

 
 

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 14 Jan 2016, 01:57 PM

Hello Jonatan,

Generally, the Kendo UI MVC wrappers are not designed to be integrated with the Kendo UI MVVM framework, because the wrappers are not meant to provide easy or complete control over the widgets' HTML output. This is explained in the documentation:

http://docs.telerik.com/kendo-ui/intro/installation/markup

http://docs.telerik.com/kendo-ui/aspnet-mvc/kendo-ui-vs-mvc-wrappers

We do not plan enhancing the MVC wrappers with MVVM capabilities, because the two techniques are too different.

A possible way to achieve the desired behavior is to use the Grid's edit event and customize the styling of the popup edit form content programmatically.

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-edit

You can also use the edit event to attach some additional event handlers to manipulate the edit form when/if needed.

An alternative approach is to include HTML elements with MVVM data attributes in the editor template for the desired field. These bindings will work.

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/editor-templates

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Jonatan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or