Pending Review
Last Updated: 12 Mar 2015 07:41 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
2 comments
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.