Completed
Last Updated: 08 Jul 2021 12:58 by ADMIN
Franz
Created on: 21 Jun 2012 18:34
Category: Data Source
Type: Feature Request
15
Allow Javascript expressions and function calls in MVVM bindings
Currently Kendo MVVM only supports a very simple binding syntax, one view attribute can be bound to one model attribute. I'd like to have real javascript expressions or function calls in bindings to support more complex scenarios, e.g. you only want to show the "submit" button in a form when all fields have been completed.

KnockOutJS supports this: http://knockoutjs.com/documentation/visible-binding.html#note_using_functions_and_expressions_to_control_element_visibility
3 comments
ADMIN
Angel Petrov
Posted on: 08 Jul 2021 12:58

Hi,

The last approach is supported and is the way we should go here. Here is a small dojo that illustrates this.

Regards,
Angel Petrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Imported User
Posted on: 02 Mar 2013 11:55
Not good to have expressions in the View. This brakes Separation of concerns principle. 
It would be better to support providing method parameters binding expression like in this example: 
<div data-bind="visible: controlVM.isVIsible(5)"> </div> 
ant then in code file 
controlVM: { 
isVIsible function (param){ 
if(param > 2) { return true;) 
else {return false;} 
} 
}

This way you can support some declarative logic with NO CODE IN VIEW.
Or even provide VM property as a parameter, but you already have access to it trough function so this is redundant but it would look like this example:
<div data-bind="visible: controlVM.isVIsible(controlVM.someProperty)"> </div> 
Wannes
Posted on: 13 Dec 2012 13:00
Excellent idea! We should at least be able to call resuable functions with parameters.