Dynamically creating checkbox listview doesn't allow selecting.

4 posts, 0 answers
  1. Justin
    Justin avatar
    7 posts
    Member since:
    Dec 2012

    Posted 26 Dec 2012 Link to this post

    Coming from a jQuery Mobile world when you altered a listview you had to refresh the listview to get things to work. Is there anything I have to do to get dynamically created checkboxes to become selectable? The checkboxes demo works fine but when I try and generate them dynamically they won't allow selected/checked. Below is the sample template I'm trying to use which is simple enough. Thanks for your help.

    <script id="position-template" type="text/x-kendo-template">
            <input type="checkbox" value="#= Id #" />
            #= Title #
  2. Alexander Valchev
    Alexander Valchev avatar
    2887 posts

    Posted 27 Dec 2012 Link to this post

    Hi Justin,

    It is unclear how do you add the items. The recommended approach is to use the DataSource methods (for example add). In this way the ListView will automatically refresh to add the new item.

    In addition please use the checked property of the checkbox input, not the value. As an example:
    <input type="checkbox" #= (checked) ? 'checked="checked"' : '' # />

    As a general information, the widgets that are used to display data are refreshed automatically when their dataSource changes. Another important thing is that the template provides one-way binding. This means that when the user changes the state of the check box the underlying dataSource item will not change automatically. If that is your aim please hook up to the change event of the check box and set the values manually. The methods you might find helpful are: getByUid (to get the dataItem) and set (to set the new value).

    Kind regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Justin
    Justin avatar
    7 posts
    Member since:
    Dec 2012

    Posted 27 Dec 2012 Link to this post

    Thanks. It was an issue with my datasource and is now working.
  4. Martin
    Martin avatar
    1 posts
    Member since:
    Mar 2013

    Posted 18 Mar 2013 Link to this post

    Would you may describe WHAT the problem was with your datasource and HOW you solved it? Would be helpful for other people too (like me). Thanks!
Back to Top