system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.i18n system.i18n.gettext system.logging system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers

CAutoComplete

system.web.widgets
继承 class CAutoComplete » CInputWidget » CWidget » CBaseController » CComponent
可用自 1.0
版本 $Id$
CAutoComplete generates an auto-complete text field.

CAutoComplete is based on the jQuery Autocomplete.

公共属性

隐藏继承的属性

属性类型描述被定义在
actionPrefix string the prefix to the IDs of the actions. CWidget
attribute string the attribute associated with this widget. CInputWidget
autoFill boolean fill the textinput while still selecting a value, replacing the value if more is typed or something else is selected. CAutoComplete
cacheLength integer the number of backend query results to store in cache. CAutoComplete
controller CController the controller that this widget belongs to. CWidget
cssFile mixed the CSS file used for the widget. CAutoComplete
data array data that would be saved as client-side data to provide candidate selections. CAutoComplete
delay integer the delay in milliseconds the autocompleter waits after a keystroke to activate itself. CAutoComplete
extraParams array extra parameters for the backend. CAutoComplete
formatItem string a javascript function that provides advanced markup for an item. CAutoComplete
formatMatch string a javascript function that can be used to limit the data that autocomplete searches for matches. CAutoComplete
formatResult string a javascript function that provides the formatting for the value to be put into the input field. CAutoComplete
highlight boolean|string Whether and how to highlight matches in the select box. CAutoComplete
htmlOptions array additional HTML options to be rendered in the input tag CInputWidget
id string id of the widget. CWidget
inputClass string the CSS class for the input element. CAutoComplete
loadingClass string the CSS class used when the data is being loaded from backend. CAutoComplete
matchCase boolean whether or not the comparison is case sensitive. CAutoComplete
matchContains boolean whether or not the comparison looks inside (i. CAutoComplete
matchSubset boolean whether or not the autocompleter can use a cache for more specific queries. CAutoComplete
max integer limit the number of items in the select box. CAutoComplete
methodChain string the chain of method calls that would be appended at the end of the autocomplete constructor. CAutoComplete
minChars integer the minimum number of characters a user has to type before the autocompleter activates. CAutoComplete
model CModel the data model associated with this widget. CInputWidget
multiple boolean whether to allow more than one autocompleted-value to enter. CAutoComplete
multipleSeparator string seperator to put between values when using multiple option. CAutoComplete
mustMatch boolean if set to true, the autocompleter will only allow results that are presented by the backend. CAutoComplete
name string the input name. CInputWidget
options array additional options that can be passed to the constructor of the autocomplete js object. CAutoComplete
owner CBaseController owner/creator of this widget. CWidget
resultsClass string the CSS class for the dropdown list. CAutoComplete
scroll boolean whether to scroll when more results than configured via scrollHeight are available. CAutoComplete
scrollHeight integer height of scrolled autocomplete control in pixels. CAutoComplete
selectFirst boolean if this is set to true, the first autocomplete value will be automatically selected on tab/return, even if it has not been handpicked by keyboard or mouse action. CAutoComplete
textArea boolean whether to show the autocomplete using a text area. CAutoComplete
url string|array the URL that can return the candidate selections. CAutoComplete
value string the input value CInputWidget
viewPath string Returns the directory containing the view files for this widget. CWidget
width integer specify a custom width for the select box. CAutoComplete

受保护的属性

隐藏继承的属性

属性类型描述被定义在
clientOptions array the javascript options CAutoComplete

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. CComponent
__construct() Constructor. CWidget
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
actions() Returns a list of actions that are used by this widget. CWidget
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
getController() CWidget
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getId() CWidget
getOwner() CWidget
getViewFile() Looks for the view script file according to the view name. CWidget
getViewPath() Returns the directory containing the view files for this widget. CWidget
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the widget. CAutoComplete
raiseEvent() Raises an event. CComponent
registerClientScript() Registers the needed CSS and JavaScript. CAutoComplete
registerCssFile() Registers the needed CSS file. CAutoComplete
render() Renders a view. CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() Executes the widget. CWidget
setId() CWidget
widget() Creates a widget and executes it. CBaseController

受保护的方法

隐藏继承的方法

方法描述被定义在
getClientOptions() CAutoComplete
hasModel() CInputWidget
resolveNameID() CInputWidget

属性详情

autoFill 属性
public boolean $autoFill;

fill the textinput while still selecting a value, replacing the value if more is typed or something else is selected. Defaults to false.

cacheLength 属性
public integer $cacheLength;

the number of backend query results to store in cache. If set to 1 (the current result), no caching will happen. Must be >= 1. Defaults to 10.

clientOptions 属性 只读
protected array getClientOptions()

the javascript options

cssFile 属性
public mixed $cssFile;

the CSS file used for the widget. Defaults to null, meaning using the default CSS file included together with the widget. If false, no CSS file will be used. Otherwise, the specified CSS file will be included when using this widget.

data 属性
public array $data;

data that would be saved as client-side data to provide candidate selections. Each array element can be string or an associative array. The url property will be ignored if this property is set.

参见

delay 属性
public integer $delay;

the delay in milliseconds the autocompleter waits after a keystroke to activate itself. Defaults to 400.

extraParams 属性
public array $extraParams;

extra parameters for the backend. If you were to specify array('bar'=>4), the autocompleter would call the backend with a GET parameter 'bar' 4. The param can be a function that is called to calculate the param before each request.

formatItem 属性
public string $formatItem;

a javascript function that provides advanced markup for an item. For each row of results, this function will be called. The returned value will be displayed inside an LI element in the results list. Autocompleter will provide 4 parameters: the results row, the position of the row in the list of results (starting at 1), the number of items in the list of results and the search term. The default behavior assumes that a single row contains a single value.

formatMatch 属性
public string $formatMatch;

a javascript function that can be used to limit the data that autocomplete searches for matches. For example, there may be items you want displayed to the user, but don't want included in the data that's searched. The function is called with the same arguments as formatItem. Defaults to formatItem.

formatResult 属性
public string $formatResult;

a javascript function that provides the formatting for the value to be put into the input field. Again three arguments: Data, position (starting with one) and total number of data. The default behavior assumes either plain data to use as result or uses the same value as provided by formatItem.

highlight 属性
public boolean|string $highlight;

Whether and how to highlight matches in the select box. Set to false to disable. Set to a javascript function to customize. The function gets the value as the first argument and the search term as the second and must return the formatted value. Defaults to Wraps the search term in a <strong> element.

inputClass 属性
public string $inputClass;

the CSS class for the input element. Defaults to "ac_input".

loadingClass 属性
public string $loadingClass;

the CSS class used when the data is being loaded from backend. Defaults to "ac_loading".

matchCase 属性
public boolean $matchCase;

whether or not the comparison is case sensitive. Important only if you use caching. Defaults to false.

matchContains 属性
public boolean $matchContains;

whether or not the comparison looks inside (i.e. does "ba" match "foo bar") the search results. Important only if you use caching. Don't mix with autofill. Defaults to false.

matchSubset 属性
public boolean $matchSubset;

whether or not the autocompleter can use a cache for more specific queries. This means that all matches of "foot" are a subset of all matches for "foo". Usually this is true, and using this options decreases server load and increases performance. Only useful with cacheLength settings bigger than one, like 10. Defaults to true.

max 属性
public integer $max;

limit the number of items in the select box. Is also sent as a "limit" parameter with a remote request. Defaults to 10.

methodChain 属性
public string $methodChain;

the chain of method calls that would be appended at the end of the autocomplete constructor. For example, ".result(function(...){})" would cause the specified js function to execute when the user selects an option.

minChars 属性
public integer $minChars;

the minimum number of characters a user has to type before the autocompleter activates. Defaults to 1.

multiple 属性
public boolean $multiple;

whether to allow more than one autocompleted-value to enter. Defaults to false.

multipleSeparator 属性
public string $multipleSeparator;

seperator to put between values when using multiple option. Defaults to ", ".

mustMatch 属性
public boolean $mustMatch;

if set to true, the autocompleter will only allow results that are presented by the backend. Note that illegal values result in an empty input box. Defaults to false.

options 属性
public array $options;

additional options that can be passed to the constructor of the autocomplete js object. This allows you to override existing functions of the autocomplete js class (e.g. the parse() function)

If you want to provide JavaScript native code, you have to prefix the string with js: otherwise it will be enclosed by quotes.

resultsClass 属性
public string $resultsClass;

the CSS class for the dropdown list. Defaults to "ac_results".

scroll 属性
public boolean $scroll;

whether to scroll when more results than configured via scrollHeight are available. Defaults to true.

scrollHeight 属性
public integer $scrollHeight;

height of scrolled autocomplete control in pixels. Defaults to 180.

selectFirst 属性
public boolean $selectFirst;

if this is set to true, the first autocomplete value will be automatically selected on tab/return, even if it has not been handpicked by keyboard or mouse action. If there is a handpicked (highlighted) result, that result will take precedence. Defaults to true.

textArea 属性 (自版本 v1.0.4 可用)
public boolean $textArea;

whether to show the autocomplete using a text area. Defaults to false, meaning a text field is used.

url 属性
public string|array $url;

the URL that can return the candidate selections. A 'q' GET parameter will be sent with the URL which contains what the user has entered so far. If the URL is given as an array, it is considered as a route to a controller action and will be used to generate a URL using CController::createUrl; If the URL is an empty string, the currently requested URL is used. This property will be ignored if data is set.

参见

width 属性
public integer $width;

specify a custom width for the select box. Defaults to the width of the input element.

方法详情

getClientOptions() 方法
protected array getClientOptions()
{return} array the javascript options

init() 方法
public void init()

Initializes the widget. This method registers all needed client scripts and renders the autocomplete input.

registerClientScript() 方法 (自版本 v1.0.1 可用)
public void registerClientScript()

Registers the needed CSS and JavaScript.

registerCssFile() 方法 (自版本 v1.0.2 可用)
public static void registerCssFile(string $url=NULL)
$url string the CSS URL. If null, a default CSS URL will be used.

Registers the needed CSS file.