PHP Класс Prado\Web\UI\WebControls\TListControl

TListControl is a base class for list controls, such as {@link TListBox}, {@link TDropDownList}, {@link TCheckBoxList}, etc. It manages the items and their status in a list control. It also implements how the items can be populated from template and data source. The property {@link getItems} returns a list of the items in the control. To specify or determine which item is selected, use the {@link getSelectedIndex SelectedIndex} property that indicates the zero-based index of the selected item in the item list. You may also use {@link getSelectedItem SelectedItem} and {@link getSelectedValue SelectedValue} to get the selected item and its value. For multiple selection lists (such as {@link TCheckBoxList} and {@link TListBox}), property {@link getSelectedIndices SelectedIndices} is useful. TListControl implements {@link setAutoPostBack AutoPostBack} which allows a list control to postback the page if the selections of the list items are changed. The {@link setCausesValidation CausesValidation} and {@link setValidationGroup ValidationGroup} properties may be used to specify that validation be performed when auto postback occurs. There are three ways to populate the items in a list control: from template, using {@link setDataSource DataSource} and using {@link setDataSourceID DataSourceID}. The latter two are covered in {@link TDataBoundControl}. To specify items via template, using the following template syntax: When {@link setDataSource DataSource} or {@link setDataSourceID DataSourceID} is used to populate list items, the {@link setDataTextField DataTextField} and {@link setDataValueField DataValueField} properties are used to specify which columns of the data will be used to populate the text and value of the items. For example, if a data source is as follows, $dataSource=array( array('name'=>'John', 'age'=>31), array('name'=>'Cary', 'age'=>28), array('name'=>'Rose', 'age'=>35), ); setting {@link setDataTextField DataTextField} and {@link setDataValueField DataValueField} to 'name' and 'age' will make the first item's text be 'John', value be 31, the second item's text be 'Cary', value be 28, and so on. The {@link setDataTextFormatString DataTextFormatString} property may be further used to format how the item should be displayed. See {@link formatDataValue()} for an explanation of the format string. The {@link setPromptText PromptText} and {@link setPromptValue PromptValue} properties can be used to add a dummy list item that will be rendered first.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends TDataBoundControl, implements Prado\IDataRenderer
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
addParsedObject ( $object ) Adds object parsed from template to the control.
clearSelection ( ) Clears all existing selections.
getAppendDataBoundItems ( ) : boolean
getAutoPostBack ( ) : boolean
getCausesValidation ( ) : boolean
getData ( ) : string Returns the value of the selected item with the lowest cardinal index.
getDataGroupField ( ) : string
getDataTextField ( ) : string
getDataTextFormatString ( ) : string
getDataValueField ( ) : string
getEnableClientScript ( ) : boolean
getHasItems ( ) : boolean
getItemCount ( ) : integer
getItems ( ) : TListItemCollection
getPromptText ( ) : string
getPromptValue ( ) : string
getSelectedIndex ( ) : integer
getSelectedIndices ( ) : array
getSelectedItem ( ) : TListItem | null
getSelectedValue ( ) : string
getSelectedValues ( ) : array
getText ( ) : string
getValidationGroup ( ) : string
loadState ( ) Loads items from viewstate.
onSelectedIndexChanged ( $param ) Raises OnSelectedIndexChanged event when selection is changed.
onTextChanged ( $param ) Raises OnTextChanged event when selection is changed.
renderContents ( $writer ) Renders body content of the list control.
saveState ( ) Saves items into viewstate.
setAppendDataBoundItems ( $value )
setAutoPostBack ( $value ) Sets the value indicating if postback automatically.
setCausesValidation ( $value )
setData ( $value ) Selects an item by the specified value.
setDataGroupField ( $value )
setDataTextField ( $value )
setDataTextFormatString ( $value ) Sets data text format string.
setDataValueField ( $value )
setEnableClientScript ( $value )
setPromptText ( $value )
setPromptValue ( $value )
setSelectedIndex ( $index )
setSelectedIndices ( $indices )
setSelectedValue ( $value ) Sets selection by item value.
setSelectedValues ( $values )
setText ( $value )
setValidationGroup ( $value )

Защищенные методы

Метод Описание
addAttributesToRender ( $writer ) Adds attributes to renderer.
createListItemCollection ( ) : TListItemCollection Creates a collection object to hold list items.
formatDataValue ( $formatString, $value ) : string Formats the text value according to a format string.
getClientClassName ( ) : string Gets the name of the javascript class responsible for performing postback for this control.
getIsMultiSelect ( ) : boolean
getPostBackOptions ( ) : array
getTagName ( ) : string
performDataBinding ( $data ) Performs databinding to populate list items from data source.
renderClientControlScript ( $writer ) Renders the javascript for list control.
renderPrompt ( $writer ) Renders the prompt text, if any.

Приватные методы

Метод Описание
resetCachedSelections ( )

Описание методов

addAttributesToRender() защищенный Метод

Adds attributes to renderer.
protected addAttributesToRender ( $writer )

addParsedObject() публичный Метод

This method adds only {@link TListItem} objects into the {@link getItems Items} collection. All other objects are ignored.
public addParsedObject ( $object )

clearSelection() публичный Метод

Clears all existing selections.
public clearSelection ( )

createListItemCollection() защищенный Метод

This method may be overriden to create a customized collection.
protected createListItemCollection ( ) : TListItemCollection
Результат TListItemCollection the collection object

formatDataValue() защищенный Метод

If the format string is empty, the original value is converted into a string and returned. If the format string starts with '#', the string is treated as a PHP expression within which the token '{0}' is translated with the data value to be formated. Otherwise, the format string and the data value are passed as the first and second parameters in {@link sprintf}.
protected formatDataValue ( $formatString, $value ) : string
Результат string the formatted result

getAppendDataBoundItems() публичный Метод

public getAppendDataBoundItems ( ) : boolean
Результат boolean whether performing databind should append items or clear the existing ones. Defaults to false.

getAutoPostBack() публичный Метод

public getAutoPostBack ( ) : boolean
Результат boolean a value indicating whether an automatic postback to the server will occur whenever the user makes change to the list control and then tabs out of it. Defaults to false.

getCausesValidation() публичный Метод

public getCausesValidation ( ) : boolean
Результат boolean whether postback event trigger by this list control will cause input validation, default is true.

getClientClassName() защищенный Метод

Derived classes may override this method and return customized js class names.
protected getClientClassName ( ) : string
Результат string the javascript class name

getData() публичный Метод

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link getSelectedValue()}.
См. также: getSelectedValue
С версии: 3.1.0
public getData ( ) : string
Результат string the value of the selected item with the lowest cardinal index, empty if no selection.

getDataGroupField() публичный Метод

public getDataGroupField ( ) : string
Результат string the field of the data source that provides the label of the list item groups

getDataTextField() публичный Метод

public getDataTextField ( ) : string
Результат string the field of the data source that provides the text content of the list items.

getDataTextFormatString() публичный Метод

public getDataTextFormatString ( ) : string
Результат string the formatting string used to control how data bound to the list control is displayed.

getDataValueField() публичный Метод

public getDataValueField ( ) : string
Результат string the field of the data source that provides the value of each list item.

getEnableClientScript() публичный Метод

public getEnableClientScript ( ) : boolean
Результат boolean whether to render javascript.

getHasItems() публичный Метод

public getHasItems ( ) : boolean
Результат boolean whether the list control contains any items.

getIsMultiSelect() защищенный Метод

protected getIsMultiSelect ( ) : boolean
Результат boolean whether this is a multiselect control. Defaults to false.

getItemCount() публичный Метод

public getItemCount ( ) : integer
Результат integer the number of items in the list control

getItems() публичный Метод

public getItems ( ) : TListItemCollection
Результат TListItemCollection the item collection

getPostBackOptions() защищенный Метод

protected getPostBackOptions ( ) : array
Результат array postback options for JS postback code

getPromptText() публичный Метод

С версии: 3.1.1
public getPromptText ( ) : string
Результат string the prompt text which is to be displayed as the first list item.

getPromptValue() публичный Метод

См. также: getPromptText
С версии: 3.1.1
public getPromptValue ( ) : string
Результат string the prompt selection value.

getSelectedIndex() публичный Метод

public getSelectedIndex ( ) : integer
Результат integer the index (zero-based) of the item being selected, -1 if no item is selected.

getSelectedIndices() публичный Метод

public getSelectedIndices ( ) : array
Результат array list of index of items that are selected

getSelectedItem() публичный Метод

public getSelectedItem ( ) : TListItem | null
Результат TListItem | null the selected item with the lowest cardinal index, null if no item is selected.

getSelectedValue() публичный Метод

public getSelectedValue ( ) : string
Результат string the value of the selected item with the lowest cardinal index, empty if no selection

getSelectedValues() публичный Метод

public getSelectedValues ( ) : array
Результат array list of the selected item values (strings)

getTagName() защищенный Метод

protected getTagName ( ) : string
Результат string tag name of the list control

getText() публичный Метод

public getText ( ) : string
Результат string selected value

getValidationGroup() публичный Метод

public getValidationGroup ( ) : string
Результат string the group of validators which the list control causes validation upon postback

loadState() публичный Метод

This method is invoked right after control state is loaded.
public loadState ( )

onSelectedIndexChanged() публичный Метод

This method is invoked when the list control has its selection changed by end-users.
public onSelectedIndexChanged ( $param )

onTextChanged() публичный Метод

This method is invoked when the list control has its selection changed by end-users.
public onTextChanged ( $param )

performDataBinding() защищенный Метод

This method is invoked by dataBind(). You may override this function to provide your own way of data population.
protected performDataBinding ( $data )

renderClientControlScript() защищенный Метод

Renders the javascript for list control.
protected renderClientControlScript ( $writer )

renderContents() публичный Метод

This method renders items contained in the list control as the body content.
public renderContents ( $writer )

renderPrompt() защищенный Метод

Renders the prompt text, if any.
С версии: 3.1.1
protected renderPrompt ( $writer )

saveState() публичный Метод

This method is invoked right before control state is to be saved.
public saveState ( )

setAppendDataBoundItems() публичный Метод

public setAppendDataBoundItems ( $value )

setAutoPostBack() публичный Метод

An automatic postback to the server will occur whenever the user makes change to the list control and then tabs out of it.
public setAutoPostBack ( $value )

setCausesValidation() публичный Метод

public setCausesValidation ( $value )

setData() публичный Метод

This method is required by {@link \Prado\IDataRenderer}. It is the same as {@link setSelectedValue()}.
См. также: setSelectedValue
С версии: 3.1.0
public setData ( $value )

setDataGroupField() публичный Метод

public setDataGroupField ( $value )

setDataTextField() публичный Метод

public setDataTextField ( $value )

setDataTextFormatString() публичный Метод

The format string is used in {@link TDataValueFormatter::format()} to format the Text property value of each item in the list control.
См. также: TDataValueFormatter::format()
public setDataTextFormatString ( $value )

setDataValueField() публичный Метод

public setDataValueField ( $value )

setEnableClientScript() публичный Метод

public setEnableClientScript ( $value )

setPromptText() публичный Метод

С версии: 3.1.1
public setPromptText ( $value )

setPromptValue() публичный Метод

См. также: setPromptText
С версии: 3.1.1
public setPromptValue ( $value )

setSelectedIndex() публичный Метод

public setSelectedIndex ( $index )

setSelectedIndices() публичный Метод

public setSelectedIndices ( $indices )

setSelectedValue() публичный Метод

Existing selections will be cleared if the item value is found in the item collection. Note, if the value is null, existing selections will also be cleared.
public setSelectedValue ( $value )

setSelectedValues() публичный Метод

public setSelectedValues ( $values )

setText() публичный Метод

public setText ( $value )

setValidationGroup() публичный Метод

public setValidationGroup ( $value )