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 event. The events of the TActiveText (from which TAutoComplete is extended from) and onSuggestion are mutually exculsive. That is, if onTextChange and/or OnCallback events are raise, then onSuggestion will not be raise, and vice versa. The list of suggestions should be set in the onSuggestion event handler. The partial word to match the suggestion is in the TCallbackEventParameter::getCallbackParameter property. The datasource of the TAutoComplete must be set using setDataSource method. This sets the datasource for the suggestions repeater, available through the Suggestions property. Header, footer templates and other properties of the repeater can be access via the Suggestions property and its sub-properties. The 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 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 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 event is raised. The TCallbackEventParameter::getCallbackParameter 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 Separator property. The Frequency and MinChars properties sets the delay and minimum number of characters typed, respectively, before requesting for sugggestions. Use onTextChange and/or OnCallback events to handle post backs due to AutoPostBack. In the 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.
Constants Inherited From TControl |
AUTOMATIC_ID_PREFIX,
CLIENT_ID_SEPARATOR,
CS_CHILD_INITIALIZED,
CS_CONSTRUCTED,
CS_INITIALIZED,
CS_LOADED,
CS_PRERENDERED,
CS_STATE_LOADED,
ID_FORMAT,
ID_SEPARATOR,
IS_CHILD_CREATED,
IS_CREATING_CHILD,
IS_DISABLE_THEMING,
IS_DISABLE_VIEWSTATE,
IS_ID_SET,
IS_SKIN_APPLIED,
IS_STYLESHEET_APPLIED,
RF_ADAPTER,
RF_AUTO_BINDINGS,
RF_CHILD_STATE,
RF_CONTROLS,
RF_CONTROLSTATE,
RF_DATA_BINDINGS,
RF_EVENTS,
RF_NAMED_CONTROLS,
RF_NAMED_CONTROLS_ID,
RF_NAMED_OBJECTS,
RF_SKIN_ID,
|
Method Summary |
protected
TRepeater
|
|
protected
TPanel
|
|
void
|
Overrides parent implementation. Callback renderSuggestions() when page's IsCallback property is true.
|
protected
string
|
|
float
|
|
integer
|
|
protected
array
|
|
TPanel
|
|
string
|
|
TRepeater
|
|
string
|
|
void
|
This method is invoked when an autocomplete suggestion is requested.
|
void
|
This method is invoked when an autocomplete suggestion is selected.
|
void
|
Raises the callback event. This method is overrides the parent implementation.
|
void
|
Renders the suggestions during a callback respones.
|
protected
void
|
Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.
|
void
|
Renders the end tag and registers javascript effects library.
|
protected
void
|
Renders the result panel.
|
void
|
Renders the suggestions repeater.
|
void
|
|
void
|
|
void
|
|
string
|
|
void
|
|
Methods Inherited From TTextBox |
TTextBox::addAttributesToRender(), TTextBox::getAutoCompleteType(), TTextBox::getAutoPostBack(), TTextBox::getAutoTrim(), TTextBox::getCausesValidation(), TTextBox::getClientClassName(), TTextBox::getColumns(), TTextBox::getData(), TTextBox::getDataChanged(), TTextBox::getEnableClientScript(), TTextBox::getIsValid(), TTextBox::getMaxLength(), TTextBox::getPersistPassword(), TTextBox::getPostBackOptions(), TTextBox::getReadOnly(), TTextBox::getRows(), TTextBox::getSafeText(), TTextBox::getSafeTextParser(), TTextBox::getTagName(), TTextBox::getText(), TTextBox::getTextMode(), TTextBox::getValidationGroup(), TTextBox::getValidationPropertyValue(), TTextBox::getWrap(), TTextBox::loadPostData(), TTextBox::onTextChanged(), TTextBox::raisePostDataChangedEvent(), TTextBox::renderClientControlScript(), TTextBox::renderContents(), TTextBox::setAutoCompleteType(), TTextBox::setAutoPostBack(), TTextBox::setAutoTrim(), TTextBox::setCausesValidation(), TTextBox::setColumns(), TTextBox::setData(), TTextBox::setEnableClientScript(), TTextBox::setIsValid(), TTextBox::setMaxLength(), TTextBox::setPersistPassword(), TTextBox::setReadOnly(), TTextBox::setRows(), TTextBox::setText(), TTextBox::setTextMode(), TTextBox::setValidationGroup(), TTextBox::setWrap()
|
Methods Inherited From TWebControl |
TWebControl::addAttributesToRender(), TWebControl::clearStyle(), TWebControl::copyBaseAttributes(), TWebControl::createStyle(), TWebControl::getAccessKey(), TWebControl::getBackColor(), TWebControl::getBorderColor(), TWebControl::getBorderStyle(), TWebControl::getBorderWidth(), TWebControl::getCssClass(), TWebControl::getDisplay(), TWebControl::getFont(), TWebControl::getForeColor(), TWebControl::getHasStyle(), TWebControl::getHeight(), TWebControl::getStyle(), TWebControl::getTabIndex(), TWebControl::getTagName(), TWebControl::getToolTip(), TWebControl::getWidth(), TWebControl::render(), TWebControl::renderBeginTag(), TWebControl::renderContents(), TWebControl::renderEndTag(), TWebControl::setAccessKey(), TWebControl::setBackColor(), TWebControl::setBorderColor(), TWebControl::setBorderStyle(), TWebControl::setBorderWidth(), TWebControl::setCssClass(), TWebControl::setDisplay(), TWebControl::setForeColor(), TWebControl::setHeight(), TWebControl::setStyle(), TWebControl::setTabIndex(), TWebControl::setToolTip(), TWebControl::setWidth()
|
Methods Inherited From TControl |
TControl::addedControl(), TControl::addParsedObject(), TControl::addToPostDataLoader(), TControl::applyStyleSheetSkin(), TControl::autoBindProperty(), TControl::autoDataBindProperties(), TControl::bindProperty(), TControl::broadcastEvent(), TControl::bubbleEvent(), TControl::clearChildState(), TControl::clearControlState(), TControl::clearNamingContainer(), TControl::clearViewState(), TControl::convertUniqueIdToClientId(), TControl::createChildControls(), TControl::createControlCollection(), TControl::dataBind(), TControl::dataBindChildren(), TControl::dataBindProperties(), TControl::ensureChildControls(), TControl::findControl(), TControl::findControlsByID(), TControl::findControlsByType(), TControl::focus(), TControl::getAdapter(), TControl::getAllowChildControls(), TControl::getAttribute(), TControl::getAttributes(), TControl::getChildControlsCreated(), TControl::getClientID(), TControl::getControls(), TControl::getControlStage(), TControl::getControlState(), TControl::getCustomData(), TControl::getEnabled(), TControl::getEnableTheming(), TControl::getEnableViewState(), TControl::getHasAdapter(), TControl::getHasAttributes(), TControl::getHasChildInitialized(), TControl::getHasControls(), TControl::getHasInitialized(), TControl::getHasLoaded(), TControl::getHasLoadedPostData(), TControl::getHasPreRendered(), TControl::getID(), TControl::getNamingContainer(), TControl::getPage(), TControl::getParent(), TControl::getRegisteredObject(), TControl::getSkinID(), TControl::getSourceTemplateControl(), TControl::getTemplateControl(), TControl::getUniqueID(), TControl::getViewState(), TControl::getVisible(), TControl::hasAttribute(), TControl::initRecursive(), TControl::isDescendentOf(), TControl::isObjectRegistered(), TControl::loadRecursive(), TControl::loadState(), TControl::loadStateRecursive(), TControl::onDataBinding(), TControl::onInit(), TControl::onLoad(), TControl::onPreRender(), TControl::onUnload(), TControl::preRenderRecursive(), TControl::raiseBubbleEvent(), TControl::registerObject(), TControl::removeAttribute(), TControl::removedControl(), TControl::render(), TControl::renderChildren(), TControl::renderControl(), TControl::saveState(), TControl::saveStateRecursive(), TControl::setAdapter(), TControl::setAttribute(), TControl::setChildControlsCreated(), TControl::setControlStage(), TControl::setControlState(), TControl::setCustomData(), TControl::setEnabled(), TControl::setEnableTheming(), TControl::setEnableViewState(), TControl::setID(), TControl::setPage(), TControl::setSkinID(), TControl::setTemplateControl(), TControl::setViewState(), TControl::setVisible(), TControl::trackViewState(), TControl::traverseChildControls(), TControl::unbindProperty(), TControl::unloadRecursive(), TControl::unregisterObject(), TControl::__get()
|
Methods Inherited From TComponent |
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()
|
Method Details |
createRepeater
Output |
TRepeater
| new instance of TRepater to render the list of suggestions. |
Exception |
|
createResultPanel
protected TPanel createResultPanel |
() |
Output |
TPanel
| new instance of result panel. Default uses TPanel. |
Exception |
|
dataBind
Overrides parent implementation. Callback renderSuggestions() when page's IsCallback property is true.
|
getClientClassName
protected string getClientClassName |
() |
Output |
string
| corresponding javascript class name for this TActiveButton. |
Exception |
|
getFrequency
public float getFrequency |
() |
Output |
float
| maximum delay (in seconds) before requesting a suggestion. |
Exception |
|
getMinChars
public integer getMinChars |
() |
Output |
integer
| minimum number of characters before requesting a suggestion. |
Exception |
|
getPostBackOptions
protected array getPostBackOptions |
() |
Output |
array
| list of callback options. |
Exception |
|
getResultPanel
public TPanel getResultPanel |
() |
Output |
TPanel
| suggestion results panel. |
Exception |
|
getSeparator
public string getSeparator |
() |
Output |
string
| word or token separators (delimiters). |
Exception |
|
getSuggestions
Output |
TRepeater
| suggestion list repeater |
Exception |
|
getTextCssClass
public string getTextCssClass |
() |
Output |
string
| Css class name of the element to use for suggestion. |
Exception |
|
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.
|
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.
|
raiseCallbackEvent
Raises the callback event. This method is overrides the parent implementation.
If AutoPostBack is enabled it will raise OnTextChanged event event and then the OnCallback event. The OnSuggest event is raise if the request is to find sugggestions, the OnTextChanged and OnCallback events are NOT raised. This method is mainly used by framework and control developers.
|
renderCallback
Renders the suggestions during a callback respones.
|
renderClientControlScript
protected void renderClientControlScript |
(mixed $writer ) |
Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.
Input |
mixed | $writer | |
Output |
Exception |
|
renderEndTag
public void renderEndTag |
(mixed $writer ) |
Renders the end tag and registers javascript effects library.
Input |
mixed | $writer | |
Output |
Exception |
|
renderResultPanel
protected void renderResultPanel |
(THtmlWriter $writer ) |
Renders the result panel.
|
renderSuggestions
Renders the suggestions repeater.
|
setDataSource
public void setDataSource |
(array $data ) |
Input |
array | $data | data source for suggestions. |
Output |
Exception |
|
setFrequency
public void setFrequency |
(float $value ) |
Input |
float | $value | maximum delay (in seconds) before requesting a suggestion. Default is 0.4. |
Output |
Exception |
|
setMinChars
public void setMinChars |
(integer $value ) |
Input |
integer | $value | minimum number of characters before requesting a suggestion. |
Output |
Exception |
|
setSeparator
public string setSeparator |
(mixed $value ) |
Input |
mixed | $value | |
Output |
string
| word or token separators (delimiters). |
Exception |
|
setTextCssClass
public void setTextCssClass |
(string $value ) |
Input |
string | $value | Css class name of the element to use for suggestion. |
Output |
Exception |
|
|