We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Close the suggestion list

Thread ID:

Created:

Updated:

Platform:

Replies:

128542 Jan 27,2017 09:17 AM UTC Dec 5,2018 07:36 AM UTC ASP.NET MVC 3
loading
Tags: AutoComplete
Mickael DOLIVEIRA
Asked On January 27, 2017 09:17 AM UTC

Hi,

I created an autocomplete with datasource on server side.
if the value does not exist (check in on focus out), i open a modal dialog for create a new value.

if the user write a new value and click (not with tab) on other field, the suggestion list can open but it will not close.
How can we to force by javascript to close the suggestion list?

i try $(this.elementId).ejAutocomplete("close");
but i receive an exception.

Regards,
Mickael

Rekha J [Syncfusion]
Replied On January 30, 2017 11:12 AM UTC

Hi Mickael,   
  
Thanks for contacting Syncfusion Support.   
  
To achieve your requirement, we have provided a workaround solution. That is, you have to use CSS for suggestionList “display:none” when the suggestionList needs to be closed.    
  
We have created a simple sample to achieve your requirement. In our sample, we have two buttons. One button is used to open the suggestionList. Another button is used to hide the suggestionList. Both actions are done by using click event of the buttons.   
  
You can download the sample from this link:   
  
Regards,   
Rekha  


Dan
Replied On November 30, 2018 03:36 PM UTC

This doesn't appear to work when coming back from an AllowAddNew() call. The suggestion list remains open. I'm using EJ1 with MVC, version 16.3.0.29. Code looks like this Any suggestions on how to get the suggestion list to close up after the item gets added on the server? Thanks.

View
        @{
            Html.EJ().Autocomplete("Specialties")
                .Datasource((IEnumerable<Specialty>) ViewData["Specialties"])
                .AutocompleteFields(f => f.Text("Name").Key("Id"))
                .Width("100%")
                .MultiSelectMode(MultiSelectModeTypes.VisualMode)
                .AllowAddNew(true)
                .Value(Model.Specialties)
                .ClientSideEvents(c => c.Select("onSpecialtySelect"))
                .Readonly(isReadOnly)
                .HtmlAttributes(new Dictionary<string, object> {{"name", "Specialties"}})
                .Render();
        }

Script
    function onSpecialtySelect(args){ 
        if(args.text.indexOf('Add New') >= 0){ 
            var newval = args.text.replace('(Add New)',''); 
            $.ajax({ 
                url: '@Url.Action("AddSpecialty", "Contact")', 
                data: { specialtyName: newval.trim() }, 
                type: 'POST', 
                dataType: "json", 
                success: function (response) { 
                    var ac = $("#Specialties").ejAutocomplete("instance"); 
                    ac.model.dataSource.push({Name:response[0].Name,Id:response[0].Id}); 
                    ac._doneRemaining();
                    ac.suggestionList.css("display", "none");
                } 
            }); 
        } 
    } 

Controller
        [HttpPost]
        public ActionResult AddSpecialty(Specialty model, string specialtyName)
        {
            var dbContext = new MyDbContext();
            var specialty = new Specialty {Name = specialtyName };
            dbContext.Specialties.Add(specialty);
            dbContext.SaveChanges();

            return Json(dbContext.Specialties.ToList());
        }

Model
    public class Specialty {
        public int Id { get; set; }
        public string Name { get; set; }
    }



Deepa Loganathan [Syncfusion]
Replied On December 5, 2018 07:36 AM UTC

Hi Dan,  
 
We regret the delay in reply. 
 
We have analyzed your query and have updated the solution based on the analysis in an incident under your direct-trac account. Please follow up the incident for more details.  
 
  
Please click here to login to your Direct Trac login with the below link.  
 
  
  
 
Regards,  
Deepa L. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;