data-bind a viewModel element to the text of a dropdownlist

4 posts, 0 answers
  1. Matthew
    Matthew avatar
    1 posts
    Member since:
    Apr 2012

    Posted 12 Apr 2012 Link to this post

    Hi, I am new to Kendo and would like to know how I can store the text value of a dropdownlist in a viewModel element.  I have three cascading dropdowns and the value of two of them is not what I want, it is the actual text of the dropdownlist that I need.  As the dropdownlists change I would like to have a hidden html element that has a data-bind="text: viewModel.element" so it would always have the current text of the dropdownlist.

    Thank you
  2. Georgi Krustev
    Georgi Krustev avatar
    3747 posts

    Posted 17 Apr 2012 Link to this post

    Hello Matthew, 

    There are several ways to achieve your goal, which as far I understand is to persist DDL text in hidden field:
    1. The first approach is to wire the change event of the dropdownlist and set the text of the widget to hidden field. This approach excludes the MVVM.
    2. The second approach is to create a custom MVVM binder which will get the text of the dropdownlist and will set a property of the ViewModel. This property can be bound to the hidden field. Check this jsFiddle demo for more information.

    All the best,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Mark
    Mark avatar
    22 posts
    Member since:
    Aug 2015

    Posted 10 Jun 2016 in reply to Georgi Krustev Link to this post

    Georgi, we can do this onChange, but what about when the view originally loads?  IE, the dropdownlist is part of a larger viewmodel, it loads...when that DDL loads for the first time, we want to update a SPAN on the page with the TEXT from that Kendo DDL...I think we can do it with MVVM, but are having difficult time figuring it out.  HELP???  Thanks.
  4. Dimiter Topalov
    Dimiter Topalov avatar
    1297 posts

    Posted 16 Jun 2016 Link to this post

    Hi Mark,

    Please check out the following demo, showing MVVM/Widget binding for multiple Kendo UI Widgets, including a DropDownList:

    I hope this helps.

    Dimiter Topalov
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top