Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

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,

  1. function autocomplete_suggestion($sender, $param)
  2. {
  3. $token = $param->getToken(); //the partial word to match
  4. $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
  5. $sender->dataBind();
  6. }

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.

Since: 3.1
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Constants Inherited From TTextBox
DEFAULT_COLUMNS, DEFAULT_ROWS,
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
renderClientControlScript ( mixed $writer)
Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.
void
renderEndTag ( mixed $writer)
Renders the end tag and registers javascript effects library.
protected  void
Renders the result panel.
void
Renders the suggestions repeater.
void
setDataSource ( array $data)
void
setFrequency ( float $value)
void
setMinChars ( integer $value)
string
setSeparator ( mixed $value)
void
setTextCssClass ( string $value)
Methods Inherited From TActiveTextBox
TActiveTextBox::addAttributesToRender(), TActiveTextBox::getActiveControl(), TActiveTextBox::getClientClassName(), TActiveTextBox::getClientSide(), TActiveTextBox::onCallback(), TActiveTextBox::raiseCallbackEvent(), TActiveTextBox::renderClientControlScript(), TActiveTextBox::setText()
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 TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
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()

Constant Summary

Method Details

createRepeater

protected TRepeater 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

public void dataBind ()

Overrides parent implementation. Callback renderSuggestions() when page's IsCallback property is true.

Output
Exception

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

public TRepeater 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

public void onSuggest (TCallbackEventParameter $param )

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.

Input
TCallbackEventParameter$paramevent parameter to be passed to the event handlers
Output
Exception

onSuggestionSelected

public void onSuggestionSelected (TCallbackEventParameter $param )

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.

Input
TCallbackEventParameter$paramevent parameter to be passed to the event handlers
Output
Exception

raiseCallbackEvent

public void raiseCallbackEvent (TCallbackEventParameter $param )

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.

Input
TCallbackEventParameter$paramthe event parameter
Output
Exception

renderCallback

public void renderCallback (THtmlWriter $writer )

Renders the suggestions during a callback respones.

Input
THtmlWriter$writerthe renderer.
Output
Exception

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.

Input
THtmlWriter$writerthe renderer.
Output
Exception

renderSuggestions

public void renderSuggestions (THtmlWriter $writer )

Renders the suggestions repeater.

Input
THtmlWriter$writerthe renderer.
Output
Exception

setDataSource

public void setDataSource (array $data )

Input
array$datadata source for suggestions.
Output
Exception

setFrequency

public void setFrequency (float $value )

Input
float$valuemaximum delay (in seconds) before requesting a suggestion. Default is 0.4.
Output
Exception

setMinChars

public void setMinChars (integer $value )

Input
integer$valueminimum 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$valueCss class name of the element to use for suggestion.
Output
Exception