Class TAutoComplete
TAutoComplete class.
TAutoComplete is a textbox that provides a list of suggestion on the current partial word typed in the textbox. The suggestions are requested using callbacks, and raises the onSuggestion OnSuggestion event. The events of the TActiveText (from which TAutoComplete is extended from) and onSuggestion OnSuggestion are mutually exculsive. That is, if onTextChange OnTextChange and/or onCallback OnCallback events are raise, then onSuggestion OnSuggestion will not be raise, and vice versa.
The list of suggestions should be set in the onSuggestion
OnSuggestion event handler. The partial word to match the suggestion is in the
TCallbackEventParameter::getCallbackParameter
TCallbackEventParameter::CallbackParameter property. The datasource of the
TAutoComplete must be set using TAutoComplete::setDataSource()
method. This sets the
datasource for the suggestions repeater, available through the getSuggestions Suggestions property. Header, footer templates and other
properties of the repeater can be access via the getSuggestions
Suggestions property and its sub-properties.
The setTextCssClass TextCssClass property if set is used to find the element within the Suggestions.ItemTemplate and Suggestions.AlternatingItemTemplate that contains the actual text for the suggestion selected. That is, only text inside elements with CSS class name equal to setTextCssClass TextCssClass will be used as suggestions.
To return the list of suggestions back to the browser, supply a non-empty data source and call databind. For example,
function autocomplete_suggestion($sender, $param) { $token = $param->getToken(); //the partial word to match $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions $sender->dataBind(); }
The suggestion will be rendered when the TAutoComplete::dataBind()
method is called
<strong>during a callback request</strong>.
When an suggestion is selected, that is, when the use has clicked, pressed the "Enter" key, or pressed the "Tab" key, the onSuggestionSelected OnSuggestionSelected event is raised. The TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter property contains the index of the selected suggestion.
TAutoComplete allows multiple suggestions within one textbox with each word or phrase separated by any characters specified in the setSeparator Separator property. The setFrequency Frequency and setMinChars MinChars properties sets the delay and minimum number of characters typed, respectively, before requesting for sugggestions.
Use onTextChange OnTextChange and/or onCallback OnCallback events to handle post backs due to setAutoPostBack AutoPostBack.
In the getSuggestions Suggestions TRepater item template, all HTML text elements are considered as text for the suggestion. Text within HTML elements with CSS class name "informal" are ignored as text for suggestions.
- TComponent
-
TApplicationComponent
-
TControl implements IRenderable, IBindable
-
TWebControl implements IStyleable
-
TTextBox implements IPostBackDataHandler, IValidatable, IDataRenderer
-
TActiveTextBox implements ICallbackEventHandler, IActiveControl
-
TAutoComplete implements INamingContainer
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Since: 3.1
Located at Web/UI/ActiveControls/TAutoComplete.php
public
string
|
|
public
string
|
|
public
float
|
|
public
|
|
public
integer
|
|
public
|
|
public
|
|
public
string
|
|
public
|
#
raiseCallbackEvent(
Raises the callback event. This method is overrides the parent implementation. If setAutoPostBack AutoPostBack is enabled it will raise onTextChanged OnTextChanged event event and then the onCallback OnCallback event. The onSuggest OnSuggest event is raise if the request is to find sugggestions, the onTextChanged OnTextChanged and onCallback OnCallback events are NOT raised. This method is mainly used by framework and control developers. |
public
|
#
onSuggest(
This method is invoked when an autocomplete suggestion is requested. The method raises 'OnSuggest' event. If you override this method, be sure to call the parent implementation so that the event handler can be invoked. |
public
|
#
onSuggestionSelected(
This method is invoked when an autocomplete suggestion is selected. The method raises 'OnSuggestionSelected' event. If you override this method, be sure to call the parent implementation so that the event handler can be invoked. |
public
|
|
public
|
#
dataBind( )
Overrides parent implementation. Callback |
public
|
|
protected
|
|
public
|
|
protected
|
|
public
|
|
protected
|
|
public
|
|
public
|
|
protected
array
|
|
protected
|
#
renderClientControlScript( mixed $writer )
Override parent implementation, no javascript is rendered here instead the
javascript required for active control is registered in |
protected
string
|
__construct(),
addAttributesToRender(),
getActiveControl(),
getClientSide(),
onCallback(),
setText()
|
getApplication(),
getRequest(),
getResponse(),
getService(),
getSession(),
getUser(),
publishAsset(),
publishFilePath()
|
DEFAULT_COLUMNS,
DEFAULT_ROWS
|
GLOBAL_RAISE_EVENT_LISTENER
|
$_decorator
|