This is a migrated thread and some comments may be shown as answers.
Load on Demand triggers immediately in page load
1 Answer 30 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Barry
Top achievements
Rank 1
Barry asked on 10 May 2011, 10:04 AM

 

Looking into the Telerik MVC Demos, I tried out the codes for Ajax ComboBox. What I want to achieve is for the items in the ComboBox  to perform lazy loading as demonstrated in the ComboBox - Load on Demand section.  The demo worked perfectly wherein at initial load the ComboBox does not get populated until you select the combo box.

My problem is that once I implemented the codes in the demo in my project, the ComboBox behaves differently. The ActionResult that is selected in my DataBinding gets called at initial load which should not be the case. It should only get called once I select the ComboBox as demonstrated in the site.

Please help, I tried to compare but I could not find what is causing the difference in behavior.

Below is my code:

View:

              <%= Html.Telerik().ComboBox()

                          .Name("AjaxComboBox")

                          .AutoFill(true)

                                .DataBinding(binding => binding.Ajax().Select("_AjaxLoading", "Default1"))

                                            .Filterable(filtering =>

                                            {

                                                filtering.FilterMode(AutoCompleteFilterMode.StartsWith);

                                            })

                          .HighlightFirstMatch(true)

        %>

 

Controller:

        [HttpPost]

        public ActionResult _AjaxLoading(string text)

        {

            Thread.Sleep(1000);

            int maxResults = Convert.ToInt32(ConfigurationManager.AppSettings["MaxResults"]);

            SelectList list;

            IList<LookupEntity> lookupEntity = _service.GetStationNoLookup();

 

            lookupEntity = lookupEntity.Where(o => o.No.StartsWith(text)).Take(maxResults).ToList();

            list = new SelectList(lookupEntity, "No", "No");

 

           // return Json(list);

                   return new JsonResult { Data = list };

        }

 

To further clarify, what is currently happening is that the _AjaxLoading gets triggered upon page load, but based from the demos, it should only trigger once I have selected the combobox. 

Please advice. Telerik Version used is 2010.3.1318.235

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 May 2011, 11:20 AM
Hello Barry,

 
Unfortunately we was not able to observe depicted issue. Here is a test project which shows the required functionality. Please check it and if it is possible modified it in order to reproduce the described problem. Thus we will be able to observe it locally and advice you further.

Greetings,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Barry
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or