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

4 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 14 May 2012 Link to this post

    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/
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 15 May 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 15 May 2012 Link to this post

    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?

  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 15 May 2012 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready