ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Not getting the list of values in Autocomplete field
Title:
B
I
{code}
?
Hi, I am trying to use AutoComplete component to get the list of items which has the text entered in the autocompelete field. Here is my view and controller method. View: @Html.Awe().AutocompleteFor(model => model.NEChannel).Placeholder("NE").Parent("TestFIName").Controller("GetData").CssClass("form-control") Controller: public ActionResult GetItems(string v, string parent)// v is the entered text { var channelList = new string[]{}; AoSession aoSession = null; aoSession = SCcon.Con_NameService(); channelList = GetDataHelper.GetChannel(Convert.ToInt32(parent), aoSession); v = (v ?? "").ToLower().Trim(); List<string> tempResult = new List<string>(); for (var z = 0; z < channelList.Length;z++ ) { if (channelList[z].ToLower().Contains(v)) { tempResult.Add(channelList[z]); } } // return Json(tempResult); return Json(tempResult.OrderBy(model => model).Select(model => new KeyContent(model, model))); } I am not getting the autocomplete field laoded with the matching values. Also, on selecting some value from the list, I need to set this value to model.NEChannel object.
Save Changes
Cancel
test
asked at 29 Jul 2016
http://aspnetawesome.com/learn/mvc/CommonProblems#Isolate-the-problem
at 29 Jul 2016
Omu
note: you should have used the trial version, and wow!, that Layout.cshtml has way too much stuff in it, multiple versions of jquery referenced, multiple awesome themes referenced, probably incompatible jquery + jqueryui versions; I recommend you to try again to create this demo but now, start by editing the mvc min setup demo, download it here: http://aspnetawesome.com/Download/MvcMinSetupDemo
at 29 Jul 2016
Omu
also the point of the prefix is to make 2 controls with the same name have different ids, but if you set the same prefix to both it makes no sens, in VS you can write .Prefix( and hit Ctrl+Shift+Space and you'll get explanation of the method, but only if you copied Omu.AwesomeMvc.xml in your libs;
at 29 Jul 2016
Omu
and you can use the awesome popup http://demo.aspnetawesome.com/PopupDemo
at 29 Jul 2016
Omu
Can you please provide me a simple demo of a Autocomplete component inside a pop up.
at 29 Jul 2016
test
Its working fine when I am trying to create Autocomplete inside the pop up window created on click of create button on homepage while running the example you shared. But in the application which I shared with you earlier, as you can see, its not working inside pop up. Please help me resolve in the test sample which I shared.
at 29 Jul 2016
test
Or Please provide a simple sample example of pop up with one Autocomplete component so that I can reuse the same in my application.
at 29 Jul 2016
test
Answers
B
I
{code}
?
download this demo: http://aspnetawesome.com/Download/MvcMinSetupDemo edit DinnerInput.cs Name property: [Required] [UIHint("Autocomplete")] [AweUrl(Action = "GetAutocomplete", Controller = "Data")] public string Name { get; set; } in DataController.cs add this: public ActionResult GetAutocomplete(string v) { v = (v ?? "").ToLower().Trim(); return Json(Db.Meals.Where(o => o.Name.ToLower().Contains(v)) .Select(o => new KeyContent(o.Id, o.Name, false))); } rebuild, run, click create
Save Changes
Cancel
Omu
answered at 30 Jul 2016
Dont we need to include anything in view for this.
at 01 Aug 2016
test
Is there any restriction to use Autocomplete that it can be only inside Awe pop up and not the regular dialog or modal !
at 01 Aug 2016
test
yes, http://stackoverflow.com/a/17755328/112100; awe popup loads content via ajax, so the autocomplete is loaded after the dialog and the problem mentioned is avoided; you can do something like: <button type="button" class="awe-btn" id="b1">open dialog</button> <script> $(function() { $('#dialog1').dialog({ autoOpen: false }); //dialog before $('#b1') .click(function() { $('#dialog1').dialog('open'); }); }); </script> <div id="dialog1">@Html.Awe().Autocomplete("da").Url(Url.Action("GetAutocomplete", "Data"))</div>
at 01 Aug 2016
Omu
Thank you, its working now.
at 01 Aug 2016
test
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK