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

Binding Data Source to Multiple Labels

1 Answer 250 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 02 Apr 2019, 11:05 PM

I've bound data sources to grids and dropdownlist widgets but I haven't seen many examples or binding the data in a datasource to simple multiple labels or textboxes on a page load (in MVVM preferably).    I can bind it to a simple variable defined in the observable objects but how can I bind it to a datasource value like an array of objects?  

<script id="index" type="text/x-kendo-template">

<span data-bind="text: someTextValue"></span>

<span data-bind="text: someTextValue2"></span>

</script>

 

 

var viewModelIndex = kendo.observable({

someTextValue: '12345',

someTextValue2: '12345',

fruits: new kendo.data.DataSource({
data: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Oranges" },
{ id: 3, name: "Bananas" }
],
schema: {
model: {
fields: {
id: { type: "number" },
name: { type: "string" }
}
}
}
}),

 

 

});

 

 

.

1 Answer, 1 is accepted

Sort by
0
Perry
Top achievements
Rank 1
answered on 03 Apr 2019, 07:53 PM
Figured it out....have to create some fields in the ViewModel and then populate the fields after the datasource retrieves its data.
Tags
Data Source
Asked by
Perry
Top achievements
Rank 1
Answers by
Perry
Top achievements
Rank 1
Share this question
or