PHP Class Prado\Web\UI\ActiveControls\TAutoComplete
Warning: this class is deprecatd and will be removed in a future release.
We suggest you to investigate using {@link TJuiAutoComplete} instead.
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 {@link onSuggestion OnSuggestion}
event. The events of the TActiveText (from which TAutoComplete is extended from)
and {@link onSuggestion OnSuggestion} are mutually exculsive. That is,
if {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback}
events are raise, then {@link onSuggestion OnSuggestion} will not be raise, and
vice versa.
The list of suggestions should be set in the {@link onSuggestion OnSuggestion}
event handler. The partial word to match the suggestion is in the
{@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
property. The datasource of the TAutoComplete must be set using {@link setDataSource}
method. This sets the datasource for the suggestions repeater, available through
the {@link getSuggestions Suggestions} property. Header, footer templates and
other properties of the repeater can be access via the {@link getSuggestions Suggestions}
property and its sub-properties.
The {@link 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 {@link 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 {@link dataBind()} method is called
during a callback request.
When an suggestion is selected, that is, when the use has clicked, pressed
the "Enter" key, or pressed the "Tab" key, the {@link onSuggestionSelected OnSuggestionSelected}
event is raised. The
{@link 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
{@link setSeparator Separator} property. The {@link setFrequency Frequency}
and {@link setMinChars MinChars} properties sets the delay and minimum number
of characters typed, respectively, before requesting for sugggestions.
Use {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback} events
to handle post backs due to {@link setAutoPostBack AutoPostBack}.
In the {@link 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.
Show file
Open project: pradosoft/prado
Public Methods
Protected Methods
Method Details
createRepeater()
protected method
protected createRepeater ( ) : TRepeater |
return |
Prado\Web\UI\WebControls\TRepeater |
new instance of TRepater to render the list of suggestions. |
createResultPanel()
protected method
protected createResultPanel ( ) : TPanel |
return |
Prado\Web\UI\WebControls\TPanel |
new instance of result panel. Default uses TPanel. |
Overrides parent implementation. Callback {@link renderSuggestions()} when
page's IsCallback property is true.
getClientClassName()
protected method
getFrequency()
public method
getMinChars()
public method
getPostBackOptions()
protected method
getResultPanel()
public method
public getResultPanel ( ) : TPanel |
return |
Prado\Web\UI\WebControls\TPanel |
suggestion results panel. |
getSeparator()
public method
getSuggestions()
public method
public getSuggestions ( ) : TRepeater |
return |
Prado\Web\UI\WebControls\TRepeater |
suggestion list repeater |
getTextCssClass()
public method
onSuggest()
public method
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.
onSuggestionSelected()
public method
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.
raiseCallbackEvent()
public method
If {@link setAutoPostBack AutoPostBack} is enabled it will raise
{@link onTextChanged OnTextChanged} event event and then the
{@link onCallback OnCallback} event. The {@link onSuggest OnSuggest} event is
raise if the request is to find sugggestions, the {@link onTextChanged OnTextChanged}
and {@link onCallback OnCallback} events are NOT raised.
This method is mainly used by framework and control developers.
renderCallback()
public method
Renders the suggestions during a callback respones.
renderClientControlScript()
protected method
Override parent implementation, no javascript is rendered here instead
the javascript required for active control is registered in {@link addAttributesToRender}.
renderEndTag()
public method
Renders the end tag and registers the needed javascript library.
renderResultPanel()
protected method
Renders the result panel.
renderSuggestions()
public method
Renders the suggestions repeater.
setDataSource()
public method
setFrequency()
public method
setMinChars()
public method
setSeparator()
public method
setTextCssClass()
public method