单个输入文本中的两个自动完成功能
我有两个自动完整功能,对于不同的文本框来说正常,我想在单个文本框中添加这两个自动完成功能值,
第一个功能:
$(function () {
$(".AccountSuplier").autocomplete({
source: '/AccAddAcount/AutoSearchSupplierAcc'
});
});
//that I used with textbox like this :
<input asp-for="Supplier" class="form-control AccountSuplier">
第二个功能:
$(function () {
$(".AutoEmplyee").autocomplete({
source: '/EmpAddEmp/AutoSearchEmploy'
});
});
<input asp-for="Emplyee" class="form-control AutoEmplyee">
这两个功能正常工作,并给出不同文本框中的供应商和Emplyees的列表,现在我想在单个文本框中添加这些列表,
//在控制器中//代码in Controller :(对于供应商,就像雇员一样)
[HttpGet]
public IActionResult AutoSearchEmploy()
{
var name = HttpContext.Request.Query["term"].ToString();
PaginatedList<EmpAddEmploy> units = _EmpAddEmpRepo.GetItems("Name", SortOrder.Ascending, "", 1, 20);
var data = units.Where(j => j.EmployeeName.ToLower().Contains(name.ToLower())).Select(j => j.EmployeeName);
return Ok(data);
}
I have two autocomplete function , that work fine for different textboxes , I want to add these two two autocomplete function values in single text box ,
1st function :
$(function () {
$(".AccountSuplier").autocomplete({
source: '/AccAddAcount/AutoSearchSupplierAcc'
});
});
//that I used with textbox like this :
<input asp-for="Supplier" class="form-control AccountSuplier">
2nd function :
$(function () {
$(".AutoEmplyee").autocomplete({
source: '/EmpAddEmp/AutoSearchEmploy'
});
});
<input asp-for="Emplyee" class="form-control AutoEmplyee">
these two function work fine and give list of Supplier and Emplyees in different textboxes , Now I want to add these list in single textbox,
// code in controller for employ : (for Supplier is same like employ )
[HttpGet]
public IActionResult AutoSearchEmploy()
{
var name = HttpContext.Request.Query["term"].ToString();
PaginatedList<EmpAddEmploy> units = _EmpAddEmpRepo.GetItems("Name", SortOrder.Ascending, "", 1, 20);
var data = units.Where(j => j.EmployeeName.ToLower().Contains(name.ToLower())).Select(j => j.EmployeeName);
return Ok(data);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要手动组合两个查询。没有测试,它看起来像这样:
You would need to manually combine the two queries. Without testing, it would look something like this:
我尝试此尝试,但仅适用于一等班,并提供供应商的列表
I try this but it work only for 1st class and give list of Supplier