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

Unable to Bind to a DataSource

4 Answers 86 Views
DropDownList for HTML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John DeVight
Top achievements
Rank 1
John DeVight asked on 12 Jul 2012, 02:32 PM

I am unable to bind an array of JSON objects to the RadDropDownList dataSource property.

In version 2012.1.0611 it was working.

I had the following HTML defined:
<input id="taskType"
        data-win-control="Telerik.UI.RadDropDownList"
        data-win-options='{
   dataTextField: "title",
   dataValueField: "id",
        }' />
 
In the JavaScript file, I initialized the data source with the following:
taskType.winControl.dataSource = [{ id: 1, title: "Scenerio" }, { id: 2, title: "Change Request" }];


I have upgraded to 2012.1.711, and this has stopped working.

I have tried the following:
taskType.winControl._widget.dataSource = [{ id: 1, title: "Scenerio" }, { id: 2, title: "Change Request" }];

and this:
var list = new WinJS.Binding.List();
list.push({ id: 1, title: "Scenerio" });
list.push({ id: 2, title: "Change Request" });
taskType.winControl._widget.dataSource = list;

But they don't work.

Please let me know what I need to do to bind the dataSource correctly.

Regards,

John DeVight

4 Answers, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 12 Jul 2012, 03:18 PM
Hello John,

We've reworked the data binding architecture of the controls since the Preview release significantly. The dataSource property of all data bound controls is of type Telerik.Data.DataSource. This type has a data property, which contains the actual data.

As the property is preinitialized with such an object with the proper options you can directly set its data property:
taskType.winControl.dataSource.data = [{ id: 1, title: "Scenerio" }, { id: 2, title: "Change Request" }];

 or do so in the initialization options of the control:
data-win-options='{dataSource: {data: [{ id: 1, title: "Scenerio" }, { id: 2, title: "Change Request" }]}}'

Until we finish the documentation of the DataSource, please refer to the QSF and the API reference for information about the proper usage of the control.

Regards,
Simon
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
John DeVight
Top achievements
Rank 1
answered on 12 Jul 2012, 04:35 PM
That worked perfectly.  Thanks Simon!
0
Anjali
Top achievements
Rank 1
answered on 09 Aug 2013, 06:14 AM
Simon! Are You sure that this solution completely solve this issue?
0
Martin Yankov
Telerik team
answered on 09 Aug 2013, 07:57 AM
Hi Anjali,

 
Simon only described how to properly initialize and assign a DataSource to a UI control. Telerik.Data.DataSource is well documented and there are explanations and code samples about how to use it with each Telerik data-bound control. Below are two links that might help you understand DataSource better.

Data-binding RadDropDownList
Using DataSource with UI Controls

If you are experiencing a specific problem, please describe it in a new thread and we will do our best to help you solve it.

Regards,
Martin Yankov
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
DropDownList for HTML
Asked by
John DeVight
Top achievements
Rank 1
Answers by
Simon
Telerik team
John DeVight
Top achievements
Rank 1
Anjali
Top achievements
Rank 1
Martin Yankov
Telerik team
Share this question
or