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

Can you databind a function...to get "filter-like" functionality?

3 Answers 356 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 14 May 2012, 03:44 PM
I have an input box which is my "filter" and that's bound to a viewModel property.

I then also have a collection bound to a template via a function.

The idea was the function would pull on the filter value to change what shows up in the box

Am I way off-base here?...would this even work?

http://jsfiddle.net/stevescotthome/TZJ4c/8/

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 15 May 2012, 08:52 AM
Hello,

 Yes, you can. Here is the updated jsFiddle: http://jsfiddle.net/korchev/TZJ4c/17/ You need to use the get method of the observable object in order to retrieve its value and track dependencies properly. This is explained in the ObservableObject help topic from our MVVM documentation (namely the "Important: dependent methods must use the get method to get field values" section).

 Regards,

Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 15 May 2012, 04:02 PM
OH!  Ok thanks :)

Would I be able to bug you to explain how this all works (just a bit deeper than the doc)?  By that I mean, I'm binding to a function, which contains some observable properties, but how does kendo know to re-call that function when the observables change.  Does it check inside to see what functions have observables then re-call them when any of those change?

0
Atanas Korchev
Telerik team
answered on 15 May 2012, 04:07 PM
Hi,

Kendo MVVM tracks the dependencies via the get method. The latter raises an internal event telling which fields are being used. All dependent fields are then listened for changes. You can find more info in the kendo.binder.js file from the source code.

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