如何使文本框接受多个自动完成 [英] how to make textbox accept multiple autocomplete

查看:70
本文介绍了如何使文本框接受多个自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文本框,并且combobox.i为文本框设置了自动完成功能。自动完成从数据库中名为teacher的表中加载。表老师有5列。我希望文本框能够接受5列的多个自动完成,这样我们就可以从组合框中选择一个列名,我希望文本框能够在组合框中查看该列名的自动完成功能请任何有想法的人

i have textbox and a combobox.i have set an autocomplete for the textbox. the autocomplete loads from a table in database called teacher. the table teacher has 5 columns. i want the textbox to be able to accept multiple autocomplete for the 5 columns so that we i select a column name from the combobox i want the textbox to view the autocomplete for that column name on the combobox pls anybody with an idea

推荐答案

为组合框写入更改事件以及更改组合框值时





Write change event for combobox and when change the combobox value


if (jQuery(control).data('autocomplete')) {
  jQuery(control).autocomplete("destroy");
  jQuery(control).removeData('autocomplete');
}



销毁自动执行上述内容并根据组合框值调用ajax并为TextBox分配新的自动完成功能。





希望这会起作用


Destroy autocomplte something like above and call ajax according to the combobox value and assign new autocomplete to the TextBox.


Hope this will work


1.从用户界面你必须发送到逻辑2参数:所选索引列(作为 int ),以及用户在自动完成文本框中输入的字符串



如果您的应用程序是一个Web应用程序,在Windows的情况下,可以使用jQuery和AJAX调用后面的代码(或控制器操作)发送上述参数表单或WPF应用程序,您应该控制事件来执行此操作。



2.在逻辑中,您必须使用这两个参数并构建5个LINQ(每个不同的列一个)或动态选择查询然后使用它来获取来自数据库的数据。运行当前查询并仅返回格言的第一个n结果,如下例所示:

1.From the user interface you have to send to the logic 2 paramters: the index of selected column (as int), and the string input by the user in the auto-complete textbox.

If your application is a web application the parameters above can be send by using jQuery and AJAX call to the code behind (or controller action), in the case of Windows Forms or WPF application you should controls events for doing this.

2.In the logic you have to use this two parameters and build 5 LINQ (one for each different columns) or a dynamic select query then use it to get the data from the database. Run the current query and returns only the maxim first "n" results like in the example bellow:
var results = query.Take(24).Select(a => new { label = a.Name });
//
return Json(results, JsonRequestBehavior.AllowGet);


这篇关于如何使文本框接受多个自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆