Class \Prado\Web\UI\JuiControls\TJuiAutoComplete
TJuiAutoComplete 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 \Prado\Web\UI\JuiControls\onSuggestion event. The events of the TActiveText (from which TJuiAutoComplete is extended from) and \Prado\Web\UI\JuiControls\onSuggestion are mutually exculsive. That is, if \Prado\Web\UI\JuiControls\onTextChange and/or \Prado\Web\UI\JuiControls\onCallback events are raise, then \Prado\Web\UI\JuiControls\onSuggestion will not be raise, and vice versa.
The list of suggestions should be set in the \Prado\Web\UI\JuiControls\onSuggestion event handler. The partial word to match the suggestion is in the \Prado\Web\UI\ActiveControls\TCallbackEventParameter::getCallbackParameter property. The datasource of the TJuiAutoComplete must be set using setDataSource method. This sets the datasource for the suggestions repeater, available through the \Prado\Web\UI\JuiControls\getSuggestions property. Header, footer templates and other properties of the repeater can be access via the \Prado\Web\UI\JuiControls\getSuggestions property and its sub-properties.
The \Prado\Web\UI\JuiControls\setTextCssClass 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 \Prado\Web\UI\JuiControls\setTextCssClass 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 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 \Prado\Web\UI\JuiControls\onSuggestionSelected event is raised. The \Prado\Web\UI\ActiveControls\TCallbackEventParameter::getCallbackParameter property contains the index of the selected suggestion.
TJuiAutoComplete allows multiple suggestions within one textbox with each word or phrase separated by any characters specified in the \Prado\Web\UI\JuiControls\setSeparator property. The \Prado\Web\UI\JuiControls\setFrequency and \Prado\Web\UI\JuiControls\setMinChars properties sets the delay and minimum number of characters typed, respectively, before requesting for sugggestions.
Use \Prado\Web\UI\JuiControls\onTextChange and/or \Prado\Web\UI\JuiControls\onCallback events to handle post backs due to \Prado\Web\UI\JuiControls\setAutoPostBack.
In the \Prado\Web\UI\JuiControls\getSuggestions 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.
Class hierarchy
- \Prado\Web\UI\JuiControls\TJuiAutoComplete implements INamingContainer, IJuiOptions
- \Prado\Web\UI\ActiveControls\TActiveTextBox implements IActiveControl, ICallbackEventHandler
- \Prado\Web\UI\WebControls\TTextBox implements IPostBackDataHandler, IValidatable, IDataRenderer
- \Prado\Web\UI\WebControls\TWebControl implements IStyleable
- \Prado\Web\UI\TControl implements IRenderable, IBindable
- \Prado\TApplicationComponent
- \Prado\TComponent
Since: 3.1
public
|
__construct() : mixed
Creates a new callback control, sets the adapter to
TActiveControlAdapter. If you override this class, be sure to set the
adapter appropriately by, for example, by calling this constructor.
|
public
|
dataBind() : mixed
Overrides parent implementation. Callback {@see renderSuggestions()} when
page's IsCallback property is true.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
onSuggest(TCallbackEventParameter $param) : mixed
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(TCallbackEventParameter $param) : mixed
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
|
raiseCallbackEvent(TCallbackEventParameter $param) : mixed
Raises the callback event. This method is overrides the parent implementation.
If \Prado\Web\UI\JuiControls\setAutoPostBack is enabled it will raise \Prado\Web\UI\JuiControls\onTextChanged event event and then the \Prado\Web\UI\JuiControls\onCallback event. The \Prado\Web\UI\JuiControls\onSuggest event is raise if the request is to find sugggestions, the \Prado\Web\UI\JuiControls\onTextChanged and \Prado\Web\UI\JuiControls\onCallback events are NOT raised. This method is mainly used by framework and control developers. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
|
protected
|
|
protected
|
getClientClassName() : string
Gets the name of the javascript class responsible for performing postback for this control.
|
protected
|
|
protected
|
renderClientControlScript(mixed $writer) : mixed
Override parent implementation, no javascript is rendered here instead
the javascript required for active control is registered in {@see addAttributesToRender}.
|
protected
|