Conditional class binding needed (or workaround)

3 posts, 0 answers
  1. Luc
    Luc avatar
    42 posts
    Member since:
    Jul 2012

    Posted 19 Apr 2012 Link to this post

    Hi,

    Over the past few days I've been struggling to get KendoUI MVVM bindings to work for the specific use case where you want to conditionally modify the class of an HTML element. At this point in time, Kendo MVVM doesn't support this use case.

    I've even tried to create custom bindings, but there is a problem when they are used within templates. I've been offered an undocumented workaround by the KendoUI team, but I've also been warned that it might eventually break in future releases, so I don't feel comfortable using it.

    I'd like to hear from others who might have found out of the box solutions to this problem.

    P.S.: I know there is a style binding in Kendo MVVM, but this puts styling information in the code, and I don't want this. I want my style informartion to remain in css files.

    Thank you
  2. Jeff
    Jeff avatar
    66 posts
    Member since:
    May 2005

    Posted 26 Sep 2012 Link to this post

    The best work-around I've found is: data-bind="{attr:{class:someObservableFunction}}"

    But I've noticed that this binding doesn't work when rendering in a page in IE compatibility mode (so would probably fail in older versions of IE).  Does anyone know of a better way to do this?

    I agree with the author of the original post that class binding is probably more useful (or at least cleaner) than style binding.
  3. Kendo UI is VS 2017 Ready
  4. Zachary
    Zachary avatar
    23 posts
    Member since:
    Feb 2013

    Posted 31 Dec 2013 Link to this post

    I agree that class bindings are sorely missing. There is a UserVoice suggestion here: Add an MVVM css binding
Back to Top