teething problems

1 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 18 Jan 2013 Link to this post

    Ive just started using AutoComplete and Im having a few problems, basically nothing shows up when I start typing in the box, hopefully someone might be able to give me a few pointers.

    in my controller (AccountController)  I have this method

            public JsonResult GetCountries()
                RegisterModel model = new RegisterModel();
                return Json(model.Countries, JsonRequestBehavior.AllowGet);

    in my model (AccountModel)  I have this property and method

    public IEnumerable<EbsData.TimeZone> Countries { get {return GetCountries();} set{value = GetCountries();} }

    /// <summary>
            /// get all the current countries from cache or repository
            /// </summary>
            /// <returns></returns>
            private IEnumerable<EbsData.TimeZone> GetCountries()
                Service.InMemoryCache cacheProvider = new Service.InMemoryCache();
                using (var context = new EbsData.EBSEntities())
                    var countries = cacheProvider.Get("countries", () => (from c in context.TimeZones select c).ToList());
                    return countries;


    and in my view, I have this markup

                    @Html.LabelFor(m => m.Country)
                    @Html.Kendo().AutoCompleteFor(m => m.Country).Name("countriesAutoComplete").Animation(true).IgnoreCase(true).DataTextField("Country").DataSource(source =>
                                                                                                                                                                    source.Read(read =>
                                                                                                                                                                        read.Action("GetCountries", "AccountController").Data("onAdditionalData"); //Set the Action and Controller name
                                                                                                                                                                    .ServerFiltering(true); //If true the DataSource will not filter the data on the client.


    which creates this hmtl

    <label for="Country">Country</label>
    <span class="k-widget k-autocomplete k-header k-state-default" tabindex="-1" role="presentation" style="">
    <input id="countriesAutoComplete" class="k-input" type="text" name="countriesAutoComplete" data-val-required="The Country field is required." data-val="true" data-role="autocomplete" style="width: 100%;" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-owns="countriesAutoComplete_listbox" aria-autocomplete="list">

    there is data available for the autocomplete to use, and the javascript function is there, but none of the server code is being executed.  Can anyone see where Im going wrong ?

Back to Top