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

dataTextField undefined if "data" child object exists in dataSource

1 Answer 106 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Norm
Top achievements
Rank 2
Norm asked on 20 Apr 2018, 03:43 AM

Having some issues with the dropdownlist control.  

I believe this is a bug. 

 

 var data = [{"id": 1,"name": "Selection 1", "data": { "id": 4, "name": "test data 4" } },{"id": 2,"name": "Selection 2", "data": { "id": 5, "name": "test data 5" } }];

                   
                    $("#htmlElement").kendoDropDownList({
                        dataTextField: "name",
                        dataValueField: "id",
                        dataSource: data,
                    });

 

The selection is correct but the data in the drop down when selecting is incorrect. 

My API returns a list of objects that have data attached.   I would like to keep the "data" child object in my datasource but your dropdownlist does not like it. 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 23 Apr 2018, 10:39 AM
Hello Norm,

Posting here my reply from the submited support ticket with identical subject. It could be useful to someone from the community facing a similar scenario. 

"data" is a field that is used by the data source to store the data items it contains. So if you cannot change this field in the object to have a different name you could use the data source's parse configuration, in order to transform the "data" field that comes with the object to some other field that does not duplicate any of the default data source fields. See this dojo example, in which the parse option is used and "data" is converted to "data1" in the data source:
data1: response[i].data


Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DropDownList
Asked by
Norm
Top achievements
Rank 2
Answers by
Ivan Danchev
Telerik team
Share this question
or