05/05/2007 - 21:28 — criecke
自动完成部件是一个下拉选择框和文本框的混合体。象选择框的地方是你提供了一个数据列表,不象选择框而象文本框的地方是用户可以忽略所有的选择而输入他想要的内容。这对开放性的多重选择问题非常的方便。但这不是2个控件,你只能使用其中的一个。
注意选择框总是有(值/描述),例如:option的值和option体的文字。自动完成控不是这样,他们仅传递显示的值,就象文本框一样。
例子
第一眼看上去,美国州的自动完成部件并不比一个下拉选择框复杂。
< script type ="text/javascript" > ...
dojo.require("dijit.form.AutoCompleter");
dojo.require("dijit.util.parser");
</ script >
...
< select id ="setvaluetest" name ="state" dojoType ="dijit.form.AutoCompleter"
class ="myComboBox" searchField ="name" autocomplete ="false" value ="Iowa"
>
< option value ="Alabama" > Alabama </ option >
< option value ="Alaska" > Alaska </ option >
...
</ select >
Write an example for data provider-fed auto completer. Details are a little fuzzy at the moment, and the unit tests are not fully constructed.
Dijit Types, Attributes, Events and Methods
dijit.AutoCompleter
Auto-completing text box, and base class for Select widget. The drop down box's values are populated from an class called a data provider, which returns a list of values based on the characters that the user has typed into the input box.
| |||
Attributes
| |||
autoComplete | Boolean | true | If true, on losing focus, automatically copy the first entry displayed in the drop down list to the input field. |
searchField | String | name | Searches pattern match against this field. Am not sure what this means |