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

Show most recently added item in remotely bound Kendo DropDownList

1 Answer 316 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Infraestructura TI
Top achievements
Rank 1
Infraestructura TI asked on 26 Apr 2017, 12:37 PM

Hello,

I was wondering if there is a way to show the most recently added item in a Kendo DropDownList which is bound to a remote datasource (from a database, via an MVC action controller).

I tried the following approach: in the same event that adds the item, once it is added, I try to set the DropDownList.select method with the value of the last index; however, this fails, and I get some warning about a synchronous XMLHttpRequest.

According to the research I have conducted, this happens because the script is trying to assign the index to the select method way too quickly, when the dataSource has not really been updated yet. If I try to assign the select method to a previous index (e.g. i - 1) and it does so without issue (showing the second-to-last item in the list). I assume this is because the item already exists in the database and thus there are no sync issues.

I appreciate any ideas you guys can share regarding this issue.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Apr 2017, 07:36 AM
Hello Hector,

Based on the provided information I can assume that this is indeed a timing issue.

In this scenario, I can suggest using an event which indicates that the request is successful and the selected item is in the DropDown.

I can suggest using the dataBound event of the DrowDown list, as this will ensure that the new data is already available in the DropDown list:

http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#events-dataBound

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