Binding templated ul to selected dropdown item

6 posts, 1 answers
  1. Jon
    Jon avatar
    15 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    I'm trying to bind a unordered list of checkboxes to a dropdown. It's very similar to cascading dropdowns. The trouble is that when the ul is bound with the template the checkboxes aren't bound to the array in the view model right away. When I change the dropdown selected item the ul updates but the checkes don't update until I click on them. It's difficult to explain so I've created a jsbin here.

    In the example, I check App1, then select Administrator from the dropdown, and then select Instructor from the dropdown. App1 is no longer checked but if I click App2 to check it, App1 becomes checked. So the binding must have occurred.

    Any help would be appricated.
  2. Jon
    Jon avatar
    15 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Updated jsbin to Q3 SP. 

    http://jsbin.com/edanig/4/edit 
  3. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 28 Feb 2013 Link to this post

    Hi,

    The problem occurs because value binding is used for the checkbox. Setting the value through the template syntax should resolve the problem. I updated the jsBin.

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Jon
    Jon avatar
    15 posts
    Member since:
    Feb 2013

    Posted 28 Feb 2013 Link to this post

    Thanks, that works. I also found this page on Stack Overflow. It's very similar and may provide a better solution for what I'm attempting.
  5. Jon
    Jon avatar
    15 posts
    Member since:
    Feb 2013

    Posted 04 Mar 2013 Link to this post

    Daniel,

    If I provide values for the membership array in the jsbin you provided, how do I get the checkboxes to bind to it. That is, if memberships is [2,3], the checkbox for App2, and App3 isn't initially checked.
  6. Answer
    Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 06 Mar 2013 Link to this post

    Hello Jon,

    The array values should be strings in order for the values to be matched and the checkboxes checked initially. I updated the sample.

    Kind regards,
    Daniel
    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