ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Set Parent to PropId of an autocomplete
Title:
B
I
{code}
?
Hi, We are trying to make a autocomplete and a checkboxlist depending on the value of the autocomplete. autocomplete is working fine but ActionResult GetPolicies gets fired everytime when key in the autocomplete not when selecting the result from the autocomplete list, also the GroupID that passed into GetPolicies is always null; here is the code: @(Html.Awe().AutocompleteFor(o => o.GroupName) .Placeholder("Search group name or policies here") .GeneratePropId(true) .PropId(o=>o.GroupID) .Controller<AutoCompleteController>()) @Html.ValidationMessageFor(o => o.GroupID) @(Html.Awe().AjaxCheckboxListFor(x=>x.PolicyList) .Url(Url.Action("GetPolicies","AutoComplete")) .Parent(o=>o.GroupID)) MODEL: public string GroupName { get; set; } public int GroupID { get; set; } public List<string> PolicyList { get; set; } public ActionResult GetPolicies(int? GroupID) { if (GroupID == null) return null; else //EF Query return Json(result) }
Save Changes
Cancel
David
asked at 28 Oct 2015
do you ever need for the autocomplete to have a value that is not in the completion list ? if not maybe you could use an odropdown or lookup instead, both have search, or a combobox ( odropdown and combobox are mods for the AjaxRadioList http://demo.aspnetawesome.com/AjaxRadioListDemo#Custom-rendering )
at 28 Oct 2015
Omu
I am not sure I see what you mean. The autocomplete is for searching through hundreds of companies. The user interactions require the company name to be searched and selected from the completion list. Then the company ID gets also saved to another property in the model. After that the checkboxlist should populate contracts/policies based on the Company ID corresponding to the company name we selected. The number of companies is so huge that it could drown the user if using combobox or whatever other than a autocomplete search.
at 28 Oct 2015
David
the lookup will do a remote call and show only 1 page on each search, have look here: http://demo.aspnetawesome.com/LookupDemo/Misc, you can also change the search form, see the 2nd one on the linked page
at 28 Oct 2015
Omu
how does this solve the problem that the checkboxlist is not firing the jquery call based on parent change?
at 28 Oct 2015
David
adding alias to the propid solved the problem. I don't why but thanks.
at 28 Oct 2015
David
it's because all parent values are sent with parameter name "parent", unless you specify an alias; the autocomplete will trigger change on the PropId on every key, the lookup seemed like a better fit
at 28 Oct 2015
Omu
thanks, that explains!
at 29 Oct 2015
David
Answers
B
I
{code}
?
those changes did the trick @(Html.Awe().AjaxCheckboxListFor(x=>x.PolicyList) .Url(Url.Action("GetPolicies","AutoComplete")) .Parent(o=>o.GroupID,"input") ) public ActionResult GetPolicies(int? input) {}
Save Changes
Cancel
David
answered at 28 Oct 2015
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