This is a migrated thread and some comments may be shown as answers.

Bind to datasource twice

1 Answer 178 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 14 May 2013, 05:12 AM
Hi

I've a datasource 'groups' in a viewmodel, which I bind to a kendo-listview.
No I want to bind that same datasource to a second simple ul-element, but unfortunately that doesn't seem to work. What am I doing wrong here? 

All I get is a weird element inside the ul with some javascript in it.

<ul id="groupViewSelect" data-bind="source: groups" class="dropdown-menu" data-auto-bind="false">
</ul>
<script id="selectViewTemplate" type="text/x-kendo-tmpl">
    <li><span data-bind="text: Name"></span></li>
</script>
contactsGroupDataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "api/contactgroups"
            }
        },
        schema: {
            model: {
                fields: {
                    Number: { type: "integer" },
                    Name: { type: "string" }
                }
            }
        }
    });
viewModel = kendo.observable({
        groups: contactsGroupDataSource
    });

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 15 May 2013, 02:30 PM
Hello Daniel,

What type of initialization you use? The <ul> element does not have a data-role attribute nor date-template, but only source binding attribute. If you would like to create a ListView widget, please add data-role="listview" to the element.

If you would like to use the source and template binding feature, please have in mind that it is designed to work observable array not DataSource. For more information please check the source and template binding demo and corresponding documentation.

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!
Tags
Data Source
Asked by
Daniel
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or