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

DropdownList and how to refresh

9 Answers 3767 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Christine
Top achievements
Rank 1
Veteran
Christine asked on 26 May 2020, 02:48 PM

I have a popup edit screen that has a few dropdown list on it.  They work great until I do into a screen and add an item for that dropdown list and low and behold I go back to that edit screen I don't see the new item unless I exit out and go back in.  I have found dropdownlist.dataSource.read(); but I am not sure how to use that. Can someone tell me how to refresh the dropdown list please?  I would think that when I open the edit pop up screen it would do it but it does not.  I need to get an answer to this quickly.

Thanks

9 Answers, 1 is accepted

Sort by
0
Christine
Top achievements
Rank 1
Veteran
answered on 26 May 2020, 08:41 PM

I have tried all sorts of java script and events to get the dropdown list to refresh with the latest and greatest data from the table.  There is something wrong with dropdown boxes.  It should not be hard to refresh the dropdown lists.  I did try the onopen event for the dropdown in the popup but it works only once, if I go into the edit screen for that table and change the record, it does not work on following times, it holds the old information.  So again, my question is on what event do I need to put the following code:

 

function OnEdit() {
var dropdown = $("#DeviceID").data("kendoDropDownList");
dropdown.dataSource.read();
dropdown.refresh();
}
</script>

Like I said this works but not all the time on the open event of the dropdown list, only the first time.  Why is it that dropdown list are so hard to use with Kendo edit????  I have literally pulled hair out trying to find the solution and so far nothing.  8 hours today I have worked on this non stop.  This should not be that difficult to do.

 

Thanks for any assistance.  I really need to get this done as I have a deadline.

 

0
Martin
Telerik team
answered on 28 May 2020, 02:05 PM

Hello Christine,

As far as I understand the scenario, you wish to add a new item to the DropDownList, and when you again open the edit popup, that new item is not to be found in the dataSource. If that is the case, please refer to the Add New Item demo and the sync method that is used to make an update request to the server.

If that does not help you to resolve the issue, please send me a small copy of your project where I can observe the issue. I will debug it and happily assist you.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Christine
Top achievements
Rank 1
Veteran
answered on 28 May 2020, 05:38 PM
What I have is a view that holds the information for a computer system.  The name of the computer system is in that view.  I edit that name and then go to a view that holds information of a building that has that computer system.  Lest say I changed the name of the computer name from "Viper" to "Tiger".  I go back to the building view and go to the edit of that computer system "Tiger" and I pull the dropdown that list computers, instead of seeing "Tiger" I see "Viper".  the view has it right though.  I have a dataSource.read() on the edit event of the main view so from what I have seen everywhere else that should do the trick but it does not.
0
Martin
Telerik team
answered on 01 Jun 2020, 10:49 AM

Hello Christine,

Could you please provide a runnable example that reproduces the issues you are experiencing? I will be able to better understand the scenario as well as debug it. I will be happy to provide a solution for you.

Looking forward to your reply.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Christine
Top achievements
Rank 1
Veteran
answered on 01 Jun 2020, 12:32 PM

 

Due to the company I work for this is not possible to give you a working copy.  I will tell you I have used the refresh and the read in a script and placed an alert to see if the code is being hit (and it is) and the dropdowns do not update.  I am using MVC.  I can show you the script that is being called when the edit button is clicked.  I have also placed this script in the open of the edit form and open of the dropdown list but nothing works.

 

function OnEdit(e)
{
// var container = e.container;
var dropdown = $("#RecordID").data("kendoDropDownList");
dropdown.dataSource.read.Action();
dropdown.dataSource.read();

 

Like I said I have tried all sorts of things to get the dropdown list to update.  I did see a post (http://www.kendoui.com/forums/ui/combobox/can-t-refresh-reload-data-combobox.aspx) that had the same issue but it looked like there was no resolution.  Is there an issue with dropdown list b in Kendo using MVC.  I am also using Internet Explorer (Edge works fine but that is not an option as our standard is IE).  If I can get  verification that IE is the problem that would be helpful.

0
Christine
Top achievements
Rank 1
Veteran
answered on 02 Jun 2020, 07:06 PM

This does not work.  I need to have the dropdown list grab the data not only when new items are added (and sync did not work when I added new item) but when something changes.  When the popup first opens it is running the code in my control, when it open after that the code does not run, no matter if there is a change or not.  I put a breakpoint there and it just ignores it.  I am using Internet Explorer, in Edge it works but my boss says it has to work in Interne Explorer.  So what do I need to do?  How can I get a dropdown box to go grab the data after it has been first opened?  I really need to get this to work and I need to get it working really soon. 

 

Thanks.

0
Martin
Telerik team
answered on 03 Jun 2020, 11:28 AM

Hello Christine,

Attached you will find a small project with a Grid and a DropDownList in the editor popup. On the open event of the DropDownList, I am executing the read method and it is calling the controller method every time the component is opened.

Could you please modify the project to reproduce the issues you are experiencing so that I can debug them?

Looking forward to your reply.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Christine
Top achievements
Rank 1
Veteran
answered on 03 Jun 2020, 01:27 PM

I cannot run the application as I get build errors.  But I did set everything up in my code like the one you sent me and it is still reading it one time.  You said yours reads it every time?  Are you using Internet Explorer (because Edge reads it every time, even with my code)?  This is frustrating.  I have been playing with this for over two months and have gotten no where.  Please run it in Internet Explorer and see if there is an issue.  The version of Kendo I am using (and I assume I can get that by looking at the folder that the Kendo Java Scripts are in) is 2020.1.406 if that means anything.  Version of IE is IE 11.1488.17134.0 and the version of Visual Studio is VS Professional 2019 Version 16.4.6.  I am using Windows 10. Again when I run the application on IE the read happens only once when the dropdown is first displayed, after that it does not run.  In Edge the data is read every time it is called.  I am about ready to give up as I have tried everything I know to do....

 

Thanks for your assistance.  Please let me know what you find. 

0
Christine
Top achievements
Rank 1
Veteran
answered on 04 Jun 2020, 01:11 PM
I have finally found the solution!!!!  You have to set the [OutputCache(Duration = 1)] in your controller and it forces Internet Explorer to not read from the cache but to pull the data from the database.... I had to do some serious searching before I found that.  What puzzles me is that Internet Explorer reads from the cache rather than from the database and Edge reads it from the database.  So  if anyone else has issues with a dropdown list not refreshing give that a try....
Tags
DropDownList
Asked by
Christine
Top achievements
Rank 1
Veteran
Answers by
Christine
Top achievements
Rank 1
Veteran
Martin
Telerik team
Share this question
or