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

kendoDropDownList.select not working in 'Add New item' replica

2 Answers 563 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Grant asked on 16 Sep 2016, 09:43 AM

Hi, 

Im trying to create a PoC replica of some new functionality added to KendoDropDownList, adding a new Item from the noDataTemplate.

Im trying to replicate http://demos.telerik.com/kendo-ui/dropdownlist/addnewitem with a static DataSource, however once the new item is added to the dataSource its not being selected, http://dojo.telerik.com/emOWE.

Regards,
Grant

PS - This feels like a stupid question, like I've overlooked something simple. My apologies if this is the case.

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 17 Sep 2016, 02:16 PM
Hello Grant,

There are two reasons for the issue.

1) In the demo example is used dataSource.view(), not the dataSource.data(). The result from both methods is different:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-view

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

2) When the optionLabel is used, the dropdown item index will increase by 1 which is changing the item index by 1.

http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#methods-select

I modified the provided example to work as expected:

http://dojo.telerik.com/AfUga

I hope this is helpful.

Regards,
Stefan
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 19 Sep 2016, 11:59 AM

Hi Stefan, 

Thanks for the help. My problem was that I didnt take into account that 'OptionLabel' would count as an <option>, very silly.

Thanks again,
Grant

Tags
DropDownList
Asked by
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Stefan
Telerik team
Grant
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or